Questions about writing functions...
От | Bob Whitehouse |
---|---|
Тема | Questions about writing functions... |
Дата | |
Msg-id | 017501c0c916$f45134c0$a6a0fea9@amsite.com обсуждение исходный текст |
Ответы |
Re: Questions about writing functions...
|
Список | pgsql-novice |
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) RETURNS INT4 AS 'DECLARE int_input ALIAS FOR $1; int_success INT4; BEGIN int_success := 0; DELETE FROM table WHERE id = int_input; IF (output from delete operation = 1) THEN int_success := 1 END IF; RETURN int_success; END;' LANGUAGE 'plpgsql'; 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; Thanks, Bob
В списке pgsql-novice по дате отправления: