By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hunter Hillegas <li***@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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #2

P: n/a
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
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3

P: n/a
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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.