Home » SQL & PL/SQL » SQL & PL/SQL » Database closing issue
Database closing issue [message #244185] Mon, 11 June 2007 19:13 Go to next message
florida
Messages: 82
Registered: April 2006
Member
I have been using PHP for inserting 15 values into one table in Oracle 9i using PHP but forgot to use the OCILogoff() method which would logoff my PHP front end connection. I was wondering what issues might occur with the Database connection? So far about 50 records have been inserted into the database and I will probably have another 200 records when it is finished in 2 weeks so the total records will be around 250. Now I dont have access to the PHP site due to permission issues so I wont be able to correct my mistake. Please advise what kind of Database issues might happen?
Re: Database closing issue [message #244186 is a reply to message #244185] Mon, 11 June 2007 19:16 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
Do/did you ever explicitly issue a "COMMIT"?
Re: Database closing issue [message #244222 is a reply to message #244185] Tue, 12 June 2007 01:31 Go to previous messageGo to next message
TonSchoen
Messages: 24
Registered: June 2007
Junior Member
In case a connection is ended by oracle, always a commit is processed. A rollback is only performed in case it's explicite asked for.
Sor the records you added will actually be in the database.
Re: Database closing issue [message #244227 is a reply to message #244222] Tue, 12 June 2007 01:47 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
TonSchoen wrote on Tue, 12 June 2007 08:31
In case a connection is ended by oracle, always a commit is processed. A rollback is only performed in case it's explicite asked for.
Sor the records you added will actually be in the database.

Are you sure? That's a rather bold statement...

MHE

[Updated on: Tue, 12 June 2007 01:47]

Report message to a moderator

Re: Database closing issue [message #244230 is a reply to message #244222] Tue, 12 June 2007 01:49 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
TonSchoen wrote on Tue, 12 June 2007 08:31
In case a connection is ended by oracle, always a commit is processed. A rollback is only performed in case it's explicite asked for.
Sor the records you added will actually be in the database.

Huh??

Try this:
Open sqlplus and insert a record. Do not commit.
If you're on windows, open the taskmanager and end process sqlplus. On unix, do a kill -9

Open a new sqlplus session and query your inserted records.

No commit has taken place. (Thank god!!! Oracle has no way of knowing whether I'm finished or not!)

You might be confused by sqlplus' behavior. If you exit sqlplus without committing, by using the "exit" command, sqlplus does an explicit commit.
If you use "quit" however, no commit is executed. (I don't know if an explicit rollback is generated; should be easy to see by tracing the sesson though)
Also, some external drivers like JDBC have the option to autocommit statements.

[Updated on: Tue, 12 June 2007 01:52]

Report message to a moderator

Re: Database closing issue [message #244239 is a reply to message #244185] Tue, 12 June 2007 02:26 Go to previous messageGo to next message
TonSchoen
Messages: 24
Registered: June 2007
Junior Member
I found this text:

How are database transactions handled in PHP?
When using the OCI Extension Module, PHP will commit whenever ociexecute() returns successfully. One can control this behaviour by specifying OCI_COMMIT_ON_SUCCESS (the default) or OCI_DEFAULT as the second parameter to the ociexecute() function call. OCI_DEFAULT can be used to prevent statements from being auto-committed. The OCICommit() and OCIRollback() functions can then be used to control the transaction.

Note that when OCI_DEFAULT is used on any statement handle, it is inherited by the other statement handles for the connection. You cannot use a mix of autocommit/explicit commit on the same connection handle. If you want to do that you need to use ociNLogon() to get a separate handle.

The ORA Extension Module supports an autocommit mode. Use the ORA_CommitOn() and ORA_CommitOff() functions to toggle between autocommit mode and normal mode. When in normal mode (ORA_CommitOff), one can use the ORA_Commit() and ORA_Rollback() functions to control transactions.

If one doesn't commit or rollback at the end of a script, PHP will do an implicit commit. This is consistent with the way SQL*Plus works.


You can read about it on:

http://www.oracle.com/technology/tech/php/htdocs/php_faq.html
Re: Database closing issue [message #244249 is a reply to message #244239] Tue, 12 June 2007 02:52 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Ah, you were talking about PHP inner workings. Ok, I follow. The default behaviour of ODBC and DISCONNECT in SQL*plus is indeed the same.

But that's not the same as "In case a connection is ended by oracle, always a commit is processed." Wink

MHE

[Updated on: Tue, 12 June 2007 02:53]

Report message to a moderator

Re: Database closing issue [message #244254 is a reply to message #244249] Tue, 12 June 2007 03:07 Go to previous message
TonSchoen
Messages: 24
Registered: June 2007
Junior Member
You're rigth, my statement was indeed too broad and not meant in the way I wrote it down.
Previous Topic: Reading XML-files
Next Topic: Conditional Selection
Goto Forum:
  


Current Time: Sun Dec 11 08:28:51 CST 2016

Total time taken to generate the page: 0.26011 seconds