Re: Insert value input syntax of an array of types without ARRAY/ROW nor casting? - Mailing list pgsql-general

From Stefan Keller
Subject Re: Insert value input syntax of an array of types without ARRAY/ROW nor casting?
Date
Msg-id AANLkTimFfJka4p7vKM-rZDANKzzP7yRR8HS-TScZy0ds@mail.gmail.com
Whole thread Raw
In response to Re: Insert value input syntax of an array of types without ARRAY/ROW nor casting?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Responses Re: Insert value input syntax of an array of types without ARRAY/ROW nor casting?  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
List pgsql-general
Thank you for the hint.

Unfortunately it still does'nt work. I get

ERROR:  wrong record constant: »('a'«
LINE 2:  5, $${ ('a', 'aa'), ('b', 'bb') }$$ );
           ^
DETAIL:  Unexpected end of line.

Yours, S.

2011/3/19 Alban Hertroys <dalroi@solfertje.student.utwente.nl>:
> On 19 Mar 2011, at 2:33, Stefan Keller wrote:
>
>> Given the test snippet below, why do the following insert attempts fail?
>>
>> The literal constant would be the most intuitive syntax. The attempt
>> below also closely follows the documentation AFAIK:
>> http://www.postgresql.org/docs/current/static/arrays.html
>>
>> INSERT INTO mytypetable VALUES (
>>  5, '{ ('a', 'aa'), ('b', 'bb') }' );
>>> ERROR: Syntax Error
>
>
> You need to escape those quotes you put inside the literal:
>
> INSERT INTO mytypetable VALUES (
>  5, '{ (''a'', ''aa''), (''b'', ''bb'') }' );
>
> Or use dollar-quoting
(http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING):
>
> INSERT INTO mytypetable VALUES (
>  5, $${ ('a', 'aa'), ('b', 'bb') }$$ );
>
> Alban Hertroys
>
> --
> Screwing up is an excellent way to attach something to the ceiling.
>
>
> !DSPAM:1205,4d848300235885070126629!
>
>
>

pgsql-general by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: query taking much longer since Postgres 8.4 upgrade
Next
From: Vincent Veyron
Date:
Subject: Re: triggers and FK cascades