Re: Tips for re-using function results within single insert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: cgg007(at)yahoo(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Tips for re-using function results within single insert
Date: 2002-09-23 14:45:26
Message-ID: 21538.1032792326@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Friday 20 Sep 2002 5:52 pm, Chris Gamache wrote:
>> This would be nice to be able to do...
>>
>> insert into test_table (a,b) select random()::text as "myrandom",
>> encode("myrandom",'base64');

You can do this sort of thing with a level of subselect:

insert into test_table (a,b)
select myrandom, encode(myrandom, 'base64')
from (select random()::text as myrandom) ss;

Trying to let one SELECT output expression refer to another one on the
same level strikes me as a really bad idea, though.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-09-23 14:48:30 Re: [SQL] Monitoring a Query
Previous Message Bruce Momjian 2002-09-23 14:41:45 Re: output format for dates