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

From: Mary Anderson <maryfran(at)demog(dot)berkeley(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: Do I really have to convert text to varchar and varchar to varchar[] to do an INSERT?
Date: 2007-10-18 23:18:59
Message-ID: 4717E9E3.10309@demog.berkeley.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,
Here is my code:

INSERT INTO location_types (lo_location_type_id, lo_location_type)
VALUES (3, 'region');

Somehow, variants of this statement generate strange error messages.

This one gets

ERROR: array value must start with "{" or dimension information.

Another try with a UNION SELECT to persuade it to insert multiple rows
gave me

ERROR: Column lt_location_type is of CHARACTER VARYING[] but expression
is of type text.

So I changed it to
INSERT INTO location_types (lo_location_type_id, lo_location_type)
VALUES (3, VARCHAR 'region');

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.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jon Jensen 2007-10-19 00:03:00 Re: Do I really have to convert text to varchar and varchar to varchar[] to do an INSERT?
Previous Message Tom Lane 2007-10-18 14:10:39 Re: could not open file "global/pg_database"