Thread: PSql won't Let me Set Varchar Column to 'true'

PSql won't Let me Set Varchar Column to 'true'

From
Hunter Hillegas
Date:
I have two varchars on my table...

I tried to run the following:

VMGEngine=# update user_account set editor_status = 'true' and
administrator_status = 'true' where rec_num = 20;
ERROR:  column "editor_status" is of type character varying but expression
is of type boolean

I was expecting the single quotes to tell psql to treat the data as a
string, not a constant boolean value.

Can I coerce psql to do what I would like it to?

Hunter



Re: PSql won't Let me Set Varchar Column to 'true'

From
Doug McNaught
Date:
Hunter Hillegas <lists@lastonepicked.com> writes:

> I have two varchars on my table...
>
> I tried to run the following:
>
> VMGEngine=# update user_account set editor_status = 'true' and
> administrator_status = 'true' where rec_num = 20;
> ERROR:  column "editor_status" is of type character varying but expression
> is of type boolean

That's odd.  What version of PG is this?

> I was expecting the single quotes to tell psql to treat the data as a
> string, not a constant boolean value.
>
> Can I coerce psql to do what I would like it to?

An explicit cast might work:

set editor_status = 'true'::text

Why aren't you using booleans anyway?  PG knows better than you.  :)

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863

Re: PSql won't Let me Set Varchar Column to 'true'

From
"Joshua D. Drake"
Date:
Hunter Hillegas wrote:

>I have two varchars on my table...
>
>I tried to run the following:
>
>VMGEngine=# update user_account set editor_status = 'true' and
>administrator_status = 'true' where rec_num = 20;
>ERROR:  column "editor_status" is of type character varying but expression
>is of type boolean
>
>

That is kind of weird... you could probably cast it...

editor_status = 't


>I was expecting the single quotes to tell psql to treat the data as a
>string, not a constant boolean value.
>
>Can I coerce psql to do what I would like it to?
>
>Hunter
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org
>
>


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL


Re: PSql won't Let me Set Varchar Column to 'true'

From
Richard Poole
Date:
On Fri, Aug 27, 2004 at 04:58:08PM -0700, Hunter Hillegas wrote:
> I have two varchars on my table...
>
> I tried to run the following:
>
> VMGEngine=# update user_account set editor_status = 'true' and
> administrator_status = 'true' where rec_num = 20;
> ERROR:  column "editor_status" is of type character varying but expression
> is of type boolean
>
> I was expecting the single quotes to tell psql to treat the data as a
> string, not a constant boolean value.

You're mistaken about the syntax of UPDATE. Assignments should be separated
by commas not by the word 'and', which is a 2-argument operator giving a
boolean result. You want:

update user_account
set editor_status = 'true', administrator_status = 'true'
where rec_num = 20;


Richard