Forum OpenACS Q&A: Response to Transactions in PL/PgSQL ?

Collapse
Posted by Tom Jackson on

Did anyone ever get transactions to work in plpgsql? I am trying the following, which works fine with out the transaction statements:

begin transaction;

insert into ms_customer_credit_ledger (ledger_id,
 credit_id, type_id, amount, description)
values (nextval(''ms_credit_ledger_seq''),v_credit_row.credit_id,
 4,v_credit_total ,''credit for item '' || 
 NEW.item_id);

update ms_customer_credit 
 set balance = (balance - v_credit_total)
where
 credit_id = v_credit_row.credit_id;

commit;

Alternatively, can I wrap the tcl code in a transaction and have it work?