Search Postgresql Archives

Re: Finding number of rows deleted in a stored procedure

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

 



Ross Bagley wrote:

> I did come across FOUND, which leads to this:
> 
> CREATE OR REPLACE FUNCTION delete_role(del_role_pk bigint) RETURNS int AS $$
> BEGIN
>     DELETE FROM br_actor_role_mm WHERE role_fk = del_role_pk;
>     DELETE FROM br_role_permission_mm WHERE role_fk = del_role_pk;
>     DELETE FROM br_role WHERE role_pk = del_role_pk;
>     IF FOUND THEN
>         RETURN 1;
>     ELSE
>         RETURN 0;
>     END IF;
> END;
> $$ LANGUAGE plpgsql;

Right.  Use GET DIAGNOSTICS foo = ROW_COUNT

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[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