Thread: Create Produre for DROP row

Create Produre for DROP row

From
Marcos
Date:
Hi,

Does have possible create one procedure to delete a row that return TRUE
if the deletion was success or FALSE if a error occur?

The procedure for deletion I already create but I don't know how detect
if the deletion was success executed.

Languagel: plpgsql

Thanks.


Re: Create Produre for DROP row

From
Jaime Casanova
Date:
On 1/11/06, Marcos <mjs_ops@gmx.net> wrote:
> Hi,
>
> Does have possible create one procedure to delete a row that return TRUE
> if the deletion was success or FALSE if a error occur?
>
> The procedure for deletion I already create but I don't know how detect
> if the deletion was success executed.
>
> Languagel: plpgsql
>
> Thanks.
>

in 8.x.x

BEGIN

     DELETE FROM .....

EXCEPTION
       WHEN others THEN
                  ...........
END;

documentation:
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

a list of errors:
http://www.postgresql.org/docs/current/static/errcodes-appendix.html

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Re: Create Produre for DROP row

From
"Guy Rouillier"
Date:
Marcos wrote:
> Hi,
>
> Does have possible create one procedure to delete a row that return
> TRUE if the deletion was success or FALSE if a error occur?
>
> The procedure for deletion I already create but I don't know how
> detect if the deletion was success executed.

How do you define success?  A delete can do nothing and be considered
successfully executed as long as no DB errors occur.  If all you want to
know is whether or not DB errors occurred, then Jaime supplied a
solution to that.

--
Guy Rouillier


Re: Create Produre for DROP row

From
"Jim C. Nasby"
Date:
On Wed, Jan 11, 2006 at 03:40:22PM -0600, Guy Rouillier wrote:
> Marcos wrote:
> > Hi,
> >
> > Does have possible create one procedure to delete a row that return
> > TRUE if the deletion was success or FALSE if a error occur?
> >
> > The procedure for deletion I already create but I don't know how
> > detect if the deletion was success executed.
>
> How do you define success?  A delete can do nothing and be considered
> successfully executed as long as no DB errors occur.  If all you want to
> know is whether or not DB errors occurred, then Jaime supplied a
> solution to that.

I suspect http://lnk.nu/postgresql.org/7ma.html will be of use to the
original poster, in particular FOUND.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: Create Produre for DROP row

From
Marcos
Date:
> BEGIN
>
>      DELETE FROM .....
>
> EXCEPTION
>        WHEN others THEN
>                   ...........
> END;
>
> documentation:
> http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
>
> a list of errors:
> http://www.postgresql.org/docs/current/static/errcodes-appendix.html
>
> --
> regards,

Thanks.

When I use the EXCEPTION and I return a value numeric or text the
Postgresql shows a error of encoding :(... Invalid Encoding UTF-8 at...

This error only occurs when a EXCEPTION treated by me it's raised.

My database is in UTF8 encoding.

What's happen?

E.g:


EXCEPTION
      WHEN others THEN RETURN 'Error';

Marcos.