Re: How to have SQL_ERROR returned from RAISERROR within IF-BLOCK



Ming,
Thanks for you reply - Sorry that I missed it for a few days.

No, using the native client is not an option available to me here. I can not
even modify the sequence of ODBC function calls and checking of the return
types here.

As I had said in my original post, my main requirement is to have SQL_ERROR
returned with with a custom error message if some particular table exists in
the database. The only solution I could work out was to execute a query for
each of the tables within the client code and check the result-set to
identify if the table exists in the database or not.

Can you give me any other out-of-the-box suggestions to help reach any other
solution to this thing, preferably using a single SQL statement for each
table?

Thanks a lot

Regards,
Shoaib.

"Pak-Ming Cheung [MSFT]" <PakMingCheungMSFT@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:6DFF704E-82CE-4F5C-B1EB-9B091B3FDAE7@xxxxxxxxxxxxxxxx
Could you try the SQL Native Client?

Thanks,
Ming.



"M. Shoaib Surya" wrote:

Hi
I am using MS SQL Server 2000.
I want to return SQL_ERROR to my application with a custom error message
from ODBC.

From what I could find form the documentation, RAISERROR statement with
severity of 11 or more is the way for me to go.

I get it returned fine when I execute the following statement using
SQLExecDirect:
RAISERROR('My error message', 11, 1)

But it returns SQL_SUCCESS_WITH_INFO rather than SQL_ERROR when I put the
RAISERROR statement within an IF-block and execute it as follows:

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id =
OBJECT_ID('dbo.my_table')
AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
RAISERROR('My error message', 11, 1)

From what I could find in the forums makes me understand that this
happens
because I am executing a batch of statements and in this case ODBC would
return SQL_SUCCESS_WITH_INFO. But I am using a wrapper library over ODBC
and
I must have SQL_ERROR returned from SQLExecDirect. My main requirement is
to
have SQL_ERROR returned with with a custom error message if some
particular
table exists in the database. Can anyone give me any suggestions or
solutions to help achieve this thing?

Thanks in advance

Regards,
Shoaib.





.



Relevant Pages

  • Re: How to have SQL_ERROR returned from RAISERROR within IF-BLOCK
    ... The problem has been fixed in SQL Server 2005. ... even modify the sequence of ODBC function calls and checking of the return ... I want to return SQL_ERROR to my application with a custom error message ... I get it returned fine when I execute the following statement using ...
    (microsoft.public.data.odbc)
  • How to have SQL_ERROR returned from RAISERROR within IF-BLOCK
    ... I want to return SQL_ERROR to my application with a custom error message ... I get it returned fine when I execute the following statement using ... because I am executing a batch of statements and in this case ODBC would ...
    (microsoft.public.data.odbc)
  • How to have SQL_ERROR returned from RAISERROR within IF-BLOCK
    ... I want to return SQL_ERROR to my application with a custom error message ... I get it returned fine when I execute the following statement using ... because I am executing a batch of statements and in this case ODBC would ...
    (microsoft.public.sqlserver.odbc)
  • Re: blue screen
    ... Enquire, plan and execute ... Background information on Stop Error message ...
    (microsoft.public.windowsxp.general)
  • RE: Need Help on Define Names
    ... The error message is "Compile error: ... are in the workbook, execute the rest of code. ... Dim NameMatch As Boolean ...
    (microsoft.public.excel.programming)

Loading