Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

autocommit and stored procedures



Hi,

Which command granularity does the JDBC driver's autocommit have?
Does it commit after each client-side JDBC statement, or does it commit
each individual SQL statement on the server-side?
In particular, does an JDBC autocommit around the call to a stored procedure commit each statement within that stored procedure, or does it commit the
procedure as a whole?

Example:

Stored Procedure
----------------
CREATE PROCEDURE Test (n varying character,val REAL)
DECLARE	
   cid INTEGER;
BEGIN
   SELECT custid INTO cid
     FROM account
    WHERE name=n;

   UPDATE checking
      SET balance=balance-val
    WHERE custid=cid;
END;

JDBC Code
---------
Connection conn;
CallableStatement cstmt;
conn.setAutoCommit(true);
cstmt = conn.prepareCall("{call Test(?,?)}");
cstmt.setString(1, name);
cstmt.setString(2, value);
cstmt.execute();


Does PostgreSQL execute one commit after the execution of Test(),
i.e. do select and update run in one transaction?
Or will PostgreSQL commit after the select and then again after the update
inside the Test() procedure?

Does anyone know what the specified behaviour is for JDBC AutoCommit?

Many thanks

Uwe





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group