Link to home
Start Free TrialLog in
Avatar of UPRRDevelopers
UPRRDevelopers

asked on

Need to do a COMMIT after a SELECT (VB)

I am running a simple SELECT statement in VB using ADODB something like this:
Dim DBCmd as New ADODB.Command
<etc>
DBCmd.Execute "SELECT * FROM USER_DATA WHERE PERSON_ID  = '" & PersonID & "'"
Set PersonRS = DBCmd.Execute

This query works fine.  I am told that the data is actually housed in another Oracle database instance, and I need to do a "COMMIT" after the select.  How do I do this?

Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Not sure about the Oracle part, but .Execute is usually only for action queries (INSERT, UPDATE, DELETE, INSERT INTO), and not for a SELECT query.

If your query does not use parameters, give this a whirl

PersonRs.Open "SELECT * FROM USER_DATA WHERE PERSON_ID  = '" & PersonID & "'", cnYourConnectionObject
also, COMMIT is used in transactions, as in BEGIN TRAN, COMMIT TRAN, ROLLBACK TRAN.
In addition to jimhorn's last message, a COMMIT is only necessary when you have used SQL to affect a change (UPDATE, INSERT or DELETE) in the underlying table.  You do not need a Transaction when all you are doing is retrieving data (SELECT...) from the database.

AW
its good to use commit only if you do any changes in the records in the database. since select statement reads only the records, there is no use of using commit statement. commit transaction can be used only if you insert or update records. if you use commit statement in select there is no use of using it. it does nothing.
Avatar of UPRRDevelopers
UPRRDevelopers

ASKER

I know about doing a commit after an alteration, and this was a surprise to me as well.  But here's the deal.  I am doing a query on a View in Database A.  The data is actually housed in Database B.  I am told that when I do the query on the view in Database A, it is taking rollback space in Database A as it does the "cross-select".  This is gradually increasing as the queries continue, and if my users do not exit the app (or lose connection to the network before the rollback space is released) then eventually, the rollback space fills, and my other apps fail due to the lack of rollback space available.  I am told that the fix for this is to perform a commit after the select, which will apparently release the rollback space from that query immediately.  My problem is that I have no idea how to do a Commit after a Select.  Hope that makes sense.
ASKER CERTIFIED SOLUTION
Avatar of 3_S
3_S

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial