Received: from email03.aon.at (WARSL401PIP8.highway.telekom.at [195.3.96.117]) by postgresql.org (8.11.3/8.11.1) with SMTP id f64Jb0a34987 for ; Wed, 4 Jul 2001 15:37:00 -0400 (EDT) (envelope-from i.hasenoehrl@aon.at) Received: (qmail 62406 invoked from network); 4 Jul 2001 19:36:57 -0000 Received: from n681p022.adsl.highway.telekom.at (HELO irina) ([62.47.29.22]) (envelope-sender ) by qmail3.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 4 Jul 2001 19:36:57 -0000 Message-ID: <00c401c104c0$b9a03200$01011eac@irina> From: =?iso-8859-1?Q?DI_Hasen=F6hrl?= To: Subject: Kind of error-handler in a pgsql function Date: Wed, 4 Jul 2001 21:37:13 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00C1_01C104D1.7CE5DE80" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Archive-Number: 200107/40 X-Sequence-Number: 3821 This is a multi-part message in MIME format. ------=_NextPart_000_00C1_01C104D1.7CE5DE80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, When I write in psql: testdb=3D# update table1 set tableattribute=3D'any' where table_nr=3D1; if a tuple exists, I get this message=20 testdb=3D# update 1 if no tuple with table_nr=3D1 exists, I get this message testdb=3D# update 0 =20=20=20=20 Is there a possibility to make a difference in a pgsql function like this: create function updTable(text,integer) returns int AS 'DECLARE msg ALIAS FOR $1; nr ALIAS FOR $2; BEGIN update table1 set tableattribute=3Dmsg where table_nr=3Dnr; --pseudocode if update =3D 0 then return 0; else return 1; end if; END; 'language 'plpgsql'; or for a function, which inserts data: create function insTable(text,integer) returns int AS 'DECLARE msg ALIAS FOR $1; nr ALIAS FOR $2; BEGIN insert into table1 values (nr,msg); --pseudocode if error=3D cannot insert duplicate key.....then return 0; else return 1; end if; END; 'language 'plpgsql'; I want to know the result of an insert or update, because I call these func= tions from an Access form and the next steps of the program depend on these= results. I hope, someone can help me, because I didn't find anything in the docu or = mailing list. Thanks in advance Irina E-Mail: i.hasenoehrl@aon.at ------=_NextPart_000_00C1_01C104D1.7CE5DE80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
When I write in psql:
testdb=3D# update table1 set tableattribut= e=3D'any'=20 where table_nr=3D1;
    if a tuple exists, I ge= t this=20 message
testdb=3D# update 1
    if no tuple with table_= nr=3D1=20 exists, I get this message
testdb=3D# update 0
   
 
Is there a possibility to make a differenc= e in a=20 pgsql function like this:
create function updTable(text,integer) ret= urns int=20 AS
'DECLARE
   msg ALIAS FOR $1;
   nr    ALI= AS FOR=20 $2;
 BEGIN
     update table1 set= =20 tableattribute=3Dmsg where table_nr=3Dnr;
    =20 --pseudocode
       if update =3D 0=20 then
         return=20 0;
     &nbs= p;=20 else
         return=20 1;
     &nbs= p; end=20 if;
   END;
'language 'plpgsql';
 
or for a function, which inserts data:
create function insTable(text,integer) ret= urns int=20 AS
'DECLARE
   msg ALIAS FOR $1;
   nr    ALI= AS FOR=20 $2;
 BEGIN
     insert into table= 1 values=20 (nr,msg);
    =20 --pseudocode
       if error=3D cannot inser= t=20 duplicate key.....then
         return=20 0;
     &nbs= p;=20 else
         return=20 1;
     &nbs= p; end=20 if;
   END;
'language 'plpgsql';
 
I want to know the result of an insert or update, because I call these= =20 functions from an Access form and the next steps of the program depend= on=20 these results.
 
I hope, someone can help me, because I didn't find anything in the doc= u or=20 mailing list.
Thanks in advance
Irina
 
E-Mail: i.hasenoehrl@aon.at
------=_NextPart_000_00C1_01C104D1.7CE5DE80--