If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Problem with picking errors in ODBC runnig SQL with cursor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-03, 21:14
maxs maxs is offline
Registered User
 
Join Date: Feb 2003
Posts: 1
Problem with picking errors in ODBC runnig SQL with cursor

Hi,

I am having a problem getting error messages from an update script if I run it using ODBC SQL Server. It happens when I use cursor and catch error on its excecution.
Below you can find an example that works perfectly fine when you use Query Analizer and fails (well it does not fail it seems like it does not proceed) in ODBC. I cannot get any warning messages that I am supposed to get (from PRINT or RAISERROR) from this code.

ODBC calls for this code: SQLPrepare, SQLExecute and catching errors using SQLGetDiagRec.

Results: In Query Analizer - full set of data
ODBC: "start" - only

Please not: I do procced all the messages in ODBC not the first one only. It shows multiple messages for other parts of the code.

Has anybody ran into this problem before? What the solution?
Thanks,


print 'start'
declare @categoryname nvarchar(15)
declare curQL cursor local for select distinct CategoryName from northwind.dbo.categories

if (@@error <> 0)
begin
print 'error on declare'
end
else
print 'declare success'

open curQL
print 1
if (@@error <> 0)
begin
print 'error on open'
end
else
print 'open success'

goto fetchCursor

while @@FETCH_STATUS <> -1
begin
if @@FETCH_STATUS <> -2
begin
print @categoryname
end
fetchCursor:
fetch next from curQL into @categoryname
if (@@error <> 0)
begin
print 'error on fetch'
end
else
print 'fetch success'
end
print 'end'
close curQL
deallocate curQL
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On