Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Bosco Rama
On 05/31/13 16:27, David Salisbury wrote: > > It would seem related to the above to me, but apparently it's not. > --- > According to the standard, the column-list syntax should allow a list of > columns to be assigned from a single row-valued expression, > such as a sub-select: >

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread David Salisbury
On 5/31/13 4:45 PM, Bosco Rama wrote: On 05/31/13 15:33, David Salisbury wrote: And without trying too much ;), I'll bet there is no way to do this in SQL proper. i.e. I can't correlate an update with a select stmt, as in a correlated sub-query sort of way. So for this to work I would ind

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Bosco Rama
On 05/31/13 15:33, David Salisbury wrote: > > And without trying too much ;), I'll bet there is no way to do this in SQL > proper. i.e. > I can't correlate an update with a select stmt, as in a correlated sub-query > sort of way. > So for this to work I would indeed need to write a function tha

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread David Salisbury
On 5/31/13 4:21 PM, Jeff Janes wrote: On Fri, May 31, 2013 at 2:37 PM, David Salisbury mailto:salisb...@globe.gov>> wrote: I would think this would be possible. I'm on 9.0.8 I have a reference between two tables, and want to populate a field in one table with a value that's in

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Jeff Janes
On Fri, May 31, 2013 at 2:37 PM, David Salisbury wrote: > > I would think this would be possible. I'm on 9.0.8 > > I have a reference between two tables, and want to populate a field in one > table > with a value that's in the referenced table ( based on the FK reference of > course ). > > with r

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Victor Yegorov
2013/6/1 David Salisbury > I would think this would be possible. I'm on 9.0.8 > Data-Modifying CTEs are available since 9.1: http://www.depesz.com/2011/03/16/waiting-for-9-1-writable-cte/ Please note, that CTE acts as an optimization fence, therefore you might experience query slowdown. --

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Bosco Rama
On 05/31/13 14:37, David Salisbury wrote: > > I would think this would be possible. I'm on 9.0.8 IIRC, updatable CTE's don't appear until 9.1.x HTH Bosco. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/ma

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Chris Angelico
On Sat, Jun 1, 2013 at 7:37 AM, David Salisbury wrote: > > I would think this would be possible. I'm on 9.0.8 > > I have a reference between two tables, and want to populate a field in one > table > with a value that's in the referenced table ( based on the FK reference of > course ). > > with ro

[GENERAL] Using a CTE for an update

2013-05-31 Thread David Salisbury
I would think this would be possible. I'm on 9.0.8 I have a reference between two tables, and want to populate a field in one table with a value that's in the referenced table ( based on the FK reference of course ). with row as ( select my.atmos_site_id, my.stationid from my_stations my, at