Skip site navigation (1) Skip section navigation (2)

Re: Do I really have to convert text to varchar and varchar to varchar[] to do an INSERT?

From: Jon Jensen <jon(at)jenseng(dot)com>
To: Mary Anderson <maryfran(at)demog(dot)berkeley(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Do I really have to convert text to varchar and varchar to varchar[] to do an INSERT?
Date: 2007-10-19 00:03:00
Message-ID: 4717F434.8040301@jenseng.com (view raw or flat)
Thread:
Lists: pgsql-novice
> Here is the error message
>
> ERROR: column "lt_location_type is of type character varying[] but 
> expression is of type character varying.
>
> HINT: You will need to rewrite or cast the expression.
>
> Something is going on with pgsql which I truly don't understand.  
> After twenty years of working with SQL, I am pretty sure i know how to 
> write a simple INSERT statement!  Explanations would be greatly 
> appreciated.
Looks like your lt_location_type column is defined as a varchar array 
(i.e. VARCHAR[]), so it's expecting you to populate it with a varchar 
array value (e.g. '{''foo'', ''bar''}') , as opposed to simple 
varchar/text values (e.g. 'foo'). A simple alter table should resolve it 
for you:

ALTER TABLE location_types ALTER COLUMN lt_location_type TYPE VARCHAR;

Jon

In response to

pgsql-novice by date

Next:From: Dale SeaburgDate: 2007-10-21 01:23:06
Subject: Pattern matching
Previous:From: Mary AndersonDate: 2007-10-18 23:18:59
Subject: Do I really have to convert text to varchar and varchar to varchar[] to do an INSERT?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group