Solved

Need to do a COMMIT after a SELECT (VB)

Posted on 2007-12-03
6
582 Views
Last Modified: 2008-02-01
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?

0
Comment
Question by:UPRRDevelopers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20399277
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
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20399285
also, COMMIT is used in transactions, as in BEGIN TRAN, COMMIT TRAN, ROLLBACK TRAN.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 20399785
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
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20401979
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.
0
 

Author Comment

by:UPRRDevelopers
ID: 20403384
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.
0
 
LVL 10

Accepted Solution

by:
3_S earned 500 total points
ID: 20404804
In your last post you are close to the solution uprrDevelopers
It's not because you implicitly start a transaction that the database doesn't start one for you. (even for a select)
So every time you do a select (or whatever) the database starts a transaction for you. (even if you do not ask).  This takes up resources and you should release these as soon as possible.  So it its still best to start a transaction your own so you have control over it.  (else it's possible it stays open as long as your application is running.) Or in event of a crash of your program it could stay open as long as the database is running.

DBCmd.ActiveConnection.BeginTrans()
....
DBCmd.ActiveConnection.CommitTrans()
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question