T-SQL errors

Results 1 to 2 of 2

Thread: T-SQL errors

  1. #1
    Join Date
    Dec 1969

    Default T-SQL errors

    I&#039;m using code to check the existence of a record before adding it.<BR><BR>ssql = "if exists(select &#039;true&#039; from table where field=12345) <BR> begin select 0 end <BR>else <BR> begin select 1 insert into table (field) (12345) end"<BR><BR>on error resume next<BR>set rs = cn.execute(sSql)<BR>if cn.Errors.count &#060;&#062; 0 then<BR> call ErrRoutine <BR>end if<BR><BR><BR>If the insert fails for any reason, like a permission problem, I don&#039;t get the error. If I put the insert first and then the select, I get the error. How can I tell if the second statement has an error?

  2. #2
    Join Date
    Dec 1969

    Default A Suggestion...

    Are you using an RDBMS where you can build stored procedures? You may want to consider using a stored proc for this. But, it looks like you are executing an &#039;exists&#039; command that is always returning false. Can you show the exact parameters you are using for this statement, or is this exactly how you are executing the statement?

Posting Permissions

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