From: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
---|---|
To: | Stefan Keller <sfkeller(at)gmail(dot)com> |
Cc: | pgsql-general List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Insert value input syntax of an array of types without ARRAY/ROW nor casting? |
Date: | 2011-03-19 10:18:32 |
Message-ID: | 42C75038-3D65-4AFC-B6C9-04946E9934FB@solfertje.student.utwente.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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:737,4d848304235883070015353!
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2011-03-19 14:24:58 | Re: query taking much longer since Postgres 8.4 upgrade |
Previous Message | Francisco Figueiredo Jr. | 2011-03-19 01:47:21 | Re: [GENERAL] Re: [GENERAL] Re: [GENERAL] Re: [GENERAL] Different encoding for string values and identifier strings? Or (select 'tést' as tést) returns different values for string and identifier... |