Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unanswered: 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.

  2. #2
    Join Date
    Oct 2003
    Posts
    7

    Re: how to check whether sql statement is executed

    Varierty of ways...
    What queries are we talking about... can you post them? Are we talking SELECTs or UPDATE/DELETEs ?

  3. #3
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: how to check whether sql statement is executed

    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.

  4. #4
    Join Date
    Sep 2003
    Posts
    522
    how about a stored procedure that has all the statements with an IF after the first one?

  5. #5
    Join Date
    Oct 2003
    Posts
    2

    Re: how to check whether sql statement is executed

    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.

  6. #6
    Join Date
    Oct 2003
    Posts
    7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •