Thread: Delete function

Delete function

From
Secrétariat
Date:
Hello !
 
I create a delete function :
CREATE FUNCTION delalpha(varchar, integer) RETURNS boolean
    AS 'DELETE FROM public.params WHERE soc = $1 AND numpar = $2 ;
          SELECT  TRUE ;'
    LANGUAGE sql ;
Is there a way to return the number of deleted row ?
Thanks.
 
Luc

Re: Delete function

From
Richard Huxton
Date:
Secrétariat wrote:
> Hello !
>
> I create a delete function :
> CREATE FUNCTION delalpha(varchar, integer) RETURNS boolean
>     AS 'DELETE FROM public.params WHERE soc = $1 AND numpar = $2 ;
>           SELECT  TRUE ;'
>     LANGUAGE sql ;
> Is there a way to return the number of deleted row ?
> Thanks.

If you rewrote the function in plpgsql, you could use "GET DIAGNOSTICS"
- see the manual plpgsql/Obtaining the result status.

--
   Richard Huxton
   Archonet Ltd