Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully

From: Bill Moran <wmoran(at)collaborativefusion(dot)com>
To: Dale <harris_da(at)yahoo(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully
Date: 2008-08-19 11:43:24
Message-ID: 20080819074324.20cda5bf.wmoran@collaborativefusion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to Dale <harris_da(at)yahoo(dot)com(dot)au>:

> On Aug 18, 9:23 pm, Lew <no(dot)(dot)(dot)(at)lewscanon(dot)com> wrote:
> > Dale wrote:
> > > Hi,
> > > I've got some code which postgres 8.3.3 won't accept.  Postgres
> > > doesn't like the INTO clause on RETURNING INTO and I've tried
> > > following the documentation.
> >
> > > UPDATE "EntityRelation" SET "Status" = inStatus, "Modified" =
> > > Session_TimeStamp(), "ModifiedBy" = UserID() WHERE ("RelationID" =
> > > inRelationID) AND ("EntityID" = inEnityID) AND IsEqual(inRelatedID,
> > > "RelatedID") RETURNING "Default" INTO oldDefault;
> >
> > > Does anyone have any ideas if the INTO clause actually works at all
> > > for an UPDATE statement?
> >
> > <http://www.postgresql.org/docs/8.3/static/sql-update.html>
> > does not list an INTO clause for UPDATE, and when you think about it, indeed
> > such a clause doesn't make sense.
>
> http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html
>
> As per this documentation, you should be able to do it. It works for
> the INSERT command, but not UPDATE. For the INSERT command, it makes
> my code look neater and I image it's more efficient too.

Is it possible that your UPDATE command is updating multiple rows? I
don't believe RETURNING will work on an UPDATE that touches more than 1
row.

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran(at)collaborativefusion(dot)com
Phone: 412-422-3463x4023

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2008-08-19 11:47:44 Re: CASE
Previous Message Bill Moran 2008-08-19 11:34:19 Re: What's size of your PostgreSQL Database?