Home » Developer & Programmer » Precompilers, OCI & OCCI » SAVEPOINT in OCCI (11g)
SAVEPOINT in OCCI [message #673157] Fri, 09 November 2018 07:38 Go to next message
sinpeak
Messages: 54
Registered: January 2011
Location: india
Member
Hello friends,

I am writing an OCCI code where I am required to rollback transactions only upto a certain point.
Hence, I need to implement something like a SAVEPOINT.

If OCCI supports creation of SAVEPOINTS and rolling back to SAVEPOINTs, then could you please share the class/method name/details.
I could not find anything related in Connection and Environment classes.

Thanks.
sinpeak
Re: SAVEPOINT in OCCI [message #673164 is a reply to message #673157] Fri, 09 November 2018 10:21 Go to previous messageGo to next message
Michel Cadot
Messages: 65964
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I didn't try it but I think you can do it using:
Statement *stmt=conn->createStatement();
stmt->execute("savepoint XXX");
...
stmt->execute("rollback to XXX");
Re: SAVEPOINT in OCCI [message #673179 is a reply to message #673164] Sat, 10 November 2018 01:51 Go to previous messageGo to next message
sinpeak
Messages: 54
Registered: January 2011
Location: india
Member
Thanks much. It worked !
Here is the code :


create table spcheck(state number(1)); -- from SQL prompt

// In OCCI code :

	  stmt = conn->createStatement("INSERT INTO SPCHECK VALUES(1)");
		stmt->execute();

		stmt1=conn->createStatement();
		stmt1->execute("SAVEPOINT SPONE");

	  stmt2 = conn->createStatement("INSERT INTO SPCHECK VALUES(2)");
		stmt->execute();

    stmt1->execute("ROLLBACK TO SPONE");		
    conn->commit();

Only value 1 got inserted
Thanks again.
Re: SAVEPOINT in OCCI [message #673180 is a reply to message #673179] Sat, 10 November 2018 02:13 Go to previous message
Michel Cadot
Messages: 65964
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Thanks for the feedback and code, it is appreciated.

Previous Topic: OCCI rounding up higher value
Goto Forum:
  


Current Time: Thu Nov 15 17:45:24 CST 2018