Re: Can I use a query with UPDATE on its SET? - Mailing list pgsql-general

From Eus
Subject Re: Can I use a query with UPDATE on its SET?
Date
Msg-id 293630.86295.qm@web37607.mail.mud.yahoo.com
Whole thread Raw
In response to Re: Can I use a query with UPDATE on its SET?  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Can I use a query with UPDATE on its SET?
List pgsql-general
Hi Ho!

--- On Thu, 2/26/09, Craig Ringer <craig@postnewspapers.com.au> wrote:

> Eus wrote:
> > Hi Ho!
> >
> > Since I can do:
> >
> > INSERT INTO table (SELECT a_transaction.*);
> >
> > I am wondering whether I can do:
> >
> > UPDATE table SET (SELECT a_transaction.*) WHERE
> primary_key = (SELECT a_transaction.primary_key);
>
> UPDATE table SET fieldname = (SELECT ..) WHERE primary_key
> = (SELECT...)

Is it possible to eliminate the use of `fieldname' completely?
So, I just need to type `UPDATE table SET (SELECT ...) WHERE primary_key'.

I think this should be possible because if the subquery in the SET clause returns the same number of columns with the
sametypes of those of the destination table, PostgreSQL should be able to just update the values at once. 

Thanks.

> --
> Craig Ringer

Best regards,
Eus (FSF member #4445)

In this digital era, where computing technology is pervasive, your freedom depends on the software controlling those
computingdevices. 

Join free software movement today! It is free as in freedom, not as in free beer!

Join: http://www.fsf.org/jf?referrer=4445




pgsql-general by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: funny view/temp table problem with query
Next
From: Pavel Stehule
Date:
Subject: Re: Format string for ISO-8601 date and time