From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Teemu Juntunen <teemu(dot)juntunen(at)e-ngine(dot)fi> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: SELECT ROW(t.*) FROM table t and nulls with textual representation? |
Date: | 2009-12-08 15:59:37 |
Message-ID: | b42b73150912080759r563a1fe2t39ac585e92ab859f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Dec 8, 2009 at 5:43 AM, Teemu Juntunen
<teemu(dot)juntunen(at)e-ngine(dot)fi> wrote:
> Hello,
>
> is there any possibility to get null-values as text 'null' from
> dynamic select expression like
>
> SELECT ROW(t.*) FROM table t
>
> Normally you get
>
> (t1,t2,t3,,t5,,,)
>
> How can you get
>
> (t1,t2,t3,null,t5,null,null,null)
>
> I would like to use the result with dynamic update expression and update
> doesn't like of empty values, so
>
> UPDATE SET (t1,t2,t3,t4,t5,t6,t7,t8) = (t1,t2,t3,,t5,,,)
It can't be done. The problem is that the update statement has a
funky syntax which is not composite type friendly. What I would
personally like to be table to do is:
update foo set foo = (x,y,z)::foo where...
then you could do:
update foo set foo = '(a,b,)'::foo where...
Couple of posssible workarounds:
*) If you are willing to put the fields you are updating as a block
into a composite type, then you could update them as a block:
create table bar as (...)
create table foo (b bar, ...)
update foo set bar = ()::bar where...;
This isn't a general solution obviously.
*) convert your update to insert+delete:
delete from foo where...
insert into foo select '(a,b,)'::foo;
watch that race condition!
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Glyn Astill | 2009-12-08 16:03:05 | Re: LDAP configuration changes in 8.4? |
Previous Message | Magnus Hagander | 2009-12-08 15:57:04 | Re: LDAP configuration changes in 8.4? |