Link to home
Start Free TrialLog in
Avatar of vidhyalakshmi
vidhyalakshmi

asked on

How to trace the return value of shell command in VB

Hi friends

I'm executing a .sql file(which has around 100 insert statements) from VB using shell command.
If any one of the insert statements fail in .sql i want to rollback the other transactions.
Any idea how to trap it.

I'm doing like this...

nResultVal = Shell("sqlplus vri/vri@gpoint @C:\Query.sql", vbMinimizedNoFocus)

This nResultVal is not consistent also.So i'mnt able to check for the success of all the queries.

Can u let me know??

pls mail at my id vidhyalakshmi_s@infy.com

Thanks
Vidhya
Avatar of xtra111
xtra111

its always suggested to extract the file contents and execute each statement seperately to get the most accurate results.  
Just so you know what "nResultVal" really is: it's the process ID and can be used, for example, to check if the process is still running or not.

Luis
I would try to keep the processes inside the VB app if possible.  Each line could be executed individually and you will know exactly where you are in the list of insert statements.

However, I have one other option for you: stored procedures.  You could take that .sql file and create a stored procedure. You didn't mention if you were in Access, oracle, SQLServer, etc.  But all of them have a way of creating a stored procedure that can handle a rollback for any missed transactions or failures.  Also, you are more likely to have fewer errors when the procedures are compiled inside your database because they can check for dependencies at compile/test.

They also can return specific error codes (you can even customize your own error codes in the stored procedure).  This can help with your error messages or error trapping in your front end code because the message could originate from the database where whomever is doing that work knows the error best and can give a more detailed reasoning for the problem.

Dan M
dmstrat@yahoo.com
vidhyalakshmi:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
vidhyalakshmi, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

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