pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Savepoint/Rollback in functions
2+ messages / 2 participants
[nested] [flat]

* Savepoint/Rollback in functions
@ 2006-03-14 22:41 Scott Petersen <scottpetersen@softhome.net>
  2006-03-14 23:11 ` Re: Savepoint/Rollback in functions Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Scott Petersen @ 2006-03-14 22:41 UTC (permalink / raw)
  To: pgsql-sql

I am running postgres 8.1.2 on both a windows and Linux platform.

The primary method of managing business logic is through the use of 
functions.  Our primary access to the database is by using PSQL (pg/psql).

The problem that I am having is that we need to execute and implement 
"SAVEPOINT" and "ROLLBACK" functionality inside of FUNCTIONS.  The 
"SAAVEPOINT/ROLLBACK" works fine interactively.  At the present time the 
documentation does not seem to be definitive on the functionality of 
this, BUT, we placed "SAVEPOINT/ROLLBACK" commands in a test function 
and the function failed.

Question 1:  does pg/psql functions allow "SAVEPOINT/ROLLBACK" 
functionality? (if so how?)

Question 2:  if the answer to question 1 is "NO", what would be required 
to get this implemented in the standard product?

Thanks in advance for any information and help.

Scott.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Savepoint/Rollback in functions
  2006-03-14 22:41 Savepoint/Rollback in functions Scott Petersen <scottpetersen@softhome.net>
@ 2006-03-14 23:11 ` Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2006-03-14 23:11 UTC (permalink / raw)
  To: Scott Petersen <scottpetersen@softhome.net>; +Cc: pgsql-sql

Scott Petersen wrote:

Hi,

> Question 1:  does pg/psql functions allow "SAVEPOINT/ROLLBACK" 
> functionality? (if so how?)

Yes.  However, you cannot use that syntax directly.  You rather use it
by establishing EXCEPTION clauses in BEGIN/END blocks.  Upon entering
any BEGIN/END block which has an EXCEPTION clause, an implicit SAVEPOINT
is executed.  If any exception (read: error) is found while executing
the block, the savepoint will be automatically rolled back and control
passed to the EXCEPTION block.

HTH,

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-03-14 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-14 22:41 Savepoint/Rollback in functions Scott Petersen <scottpetersen@softhome.net>
2006-03-14 23:11 ` Alvaro Herrera <alvherre@commandprompt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox