From: | DI Hasenöhrl <i(dot)hasenoehrl(at)aon(dot)at> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Kind of error-handler in a pgsql function |
Date: | 2001-07-04 19:37:13 |
Message-ID: | 00c401c104c0$b9a03200$01011eac@irina |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
When I write in psql:
testdb=# update table1 set tableattribute='any' where table_nr=1;
if a tuple exists, I get this message
testdb=# update 1
if no tuple with table_nr=1 exists, I get this message
testdb=# update 0
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=msg where table_nr=nr;
--pseudocode
if update = 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= 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 functions 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(dot)hasenoehrl(at)aon(dot)at
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-07-05 00:38:25 | Re: Kind of error-handler in a pgsql function |
Previous Message | Stephen Bell | 2001-07-04 17:57:51 | Re: sql startment problem PLEASE HELP ..... |