Sunday, February 19, 2012

how to check whether sql statement is executed

Hi,
I have a few sql statements in asp. How do I check that the first sql statement is executed before the second one? If the first sql statement does not execute, then the second one will not execute too.Varierty of ways...
What queries are we talking about... can you post them? Are we talking SELECTs or UPDATE/DELETEs ?|||Originally posted by autumn6
Hi,

I have a few sql statements in asp. How do I check that the first sql statement is executed before the second one? If the first sql statement does not execute, then the second one will not execute too.

May be @.@.ROWCOUNT (Returns the number of rows affected by the last statement) will help you to find decision. You can get value from ADO.|||how about a stored procedure that has all the statements with an IF after the first one?|||Originally posted by LFN
Varierty of ways...
What queries are we talking about... can you post them? Are we talking SELECTs or UPDATE/DELETEs ?

It's a few INSERT statements.|||Its my understading that an INSERT operation will either succeed - or fail with an error (not necessarily a fatal error though)

So if its just INSERTS youre doing then check for a non-fatal error. Obviously a fatal error will abort your code anyway.

You might want to consider using a transaction... just to make sure they all go - or none as required...

Then after each INSERT do the error check...

IF (@.@.ERROR <> 0) ... [ take action - maybe a goto error routine ].....

That will catch any non-fatal errors - if there wasnt one the INSERT worked.

LFN

No comments:

Post a Comment