Re: Tips for re-using function results within single insert - Mailing list pgsql-general

From Tom Lane
Subject Re: Tips for re-using function results within single insert
Date
Msg-id 21538.1032792326@sss.pgh.pa.us
Whole thread Raw
In response to Re: Tips for re-using function results within single insert  (Richard Huxton <dev@archonet.com>)
List 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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: output format for dates
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] Monitoring a Query