Обсуждение: Delete function

Поиск
Список
Период
Сортировка

Delete function

От
Secrétariat
Дата:
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

От
Richard Huxton
Дата:
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