Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



if you are doing insert, update or delete you can use "retuirng" command in the query, work with a cursor to get the rows


----- Mensaje original -----
> 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*


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux