If I write a function that deletes a record from a table, how do I access
the output from the delete operation to see if it completed successfully?
Check out the IF statement below.
CREATE FUNCTION del_test(INT4)
int_input ALIAS FOR $1;
int_success := 0;
DELETE FROM table WHERE id = int_input;
IF (output from delete operation = 1) THEN
int_success := 1
I'm also wondering if I need to be able to trap an error and rollback the
state of the database. If so, how would I do it?
I've seen it done like this in other databases before:
EXEC SQL WHENEVER SQLERROR ROLLBACK ABORT;
pgsql-novice by date
|Next:||From: Bob Whitehouse||Date: 2001-04-19 21:30:57|
|Subject: Questions about functions...|
|Previous:||From: Peter Eisentraut||Date: 2001-04-19 15:47:58|
|Subject: Re: < Int4 - limit >|