Re: PLPGSQL: How can I get the effected rows when use "execute" command in function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Muiz <work(dot)muiz(at)gmail(dot)com>
Cc: questions(at)postgresql(dot)org
Subject: Re: PLPGSQL: How can I get the effected rows when use "execute" command in function
Date: 2011-11-29 13:59:57
Message-ID: CAFj8pRDm=WYjL072dphxUZk-jmTnMM9=3Zch7LXgdqytebM6mg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

yes, you can. Look on GET DIAGNOSTICS statement

http://www.postgresql.org/docs/9.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

Regards

Pavel Stehule

2011/11/29 Muiz <work(dot)muiz(at)gmail(dot)com>:
> Dear all,
>
>    Can I get the effected rows after executing sqls in function?
> e.g.:
>
> CREATE OR REPLACE FUNCTION execsqls(sqls character varying)
>   RETURNS integer AS
> $BODY$
> DECLARE
> BEGIN
>            EXECUTE sqls;
>            -- TODO-1: I want to know how many records the input sqls
> effects?
>            RETURN effectedRows;
> END;
> $BODY$
>   LANGUAGE plpgsql;
>
> test: select  execsqls('update mytable where name like ''%abc''')
>
> --
> Regards,
> Muiz
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ernesto Quiniones 2011-11-29 14:03:49 Re: PLPGSQL: How can I get the effected rows when use "execute" command in function
Previous Message Heiko Wundram 2011-11-29 13:49:37 Limiting number of connections to PostgreSQL per IP (not per DB/user)?