Re: How to find out if row was modified by EXECUTE UPDATE ...

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to find out if row was modified by EXECUTE UPDATE ...
Date: 2010-03-08 12:18:16
Message-ID: 162867791003080418j7d083b18h7123540f0c8af36a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2010/3/8 A B <gentosaker(at)gmail(dot)com>:
> Hello.
> Doesn't this work in plpgsql functions?
>
> EXECUTE 'UPDATE mytable set ... ...'
> IF FOUND THEN
>       do stuff....
> END IF;
>

it doesn't work - you have to use GET DIAGNOSTICS statement

GET DIAGNOSTICS integer_var = ROW_COUNT;
http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

regards
Pavel Stehule

> It seems it always evaluate to false in the if statement, Isn't  found
> used to see if an update has modified rows?
>
> Are there any alternatives to selecting the row and see if the values
> are set to see if the update worked?
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Roffler 2010-03-08 12:23:32 Re: XML Index again
Previous Message A B 2010-03-08 12:12:32 How to find out if row was modified by EXECUTE UPDATE ...