[freetds] Error when using nocount, insert and print statements together.

M A manwar1tech at yahoo.com
Fri Oct 21 14:40:20 EDT 2005


Hi,
This might be related to the previous post for the same error, but this will show up every time.
 
The following error is reported when a certain executing a certain set of commands in a stored procedure. On the previous version it would not execute all the statements but on version 0.63 it reports the following error.
 
 Attempt to initiate a new SQL Server operation with results pending.
 
This is using the stable releaese of freetds: version 0.63
 

To reproduce the error create the table and stored procedure on SQL server using the following code:
 
create table test_api([updated_date] datetime, [id] int)

create proc testProc
AS
BEGIN
set nocount on
insert into test_api values(getDate(), 1)
insert into test_api values(getDate(), 2)
print 'About to call select'
select updated_date,id from test_api
print 'Did the select'
END
 
Now call the testProc from freetds using 
dbcmd("exec testProc")
 
 
and the error will show up.
however the following set of commands work.. 
It seems like set nocount on followed by an  insert statement followed by a print statement will fail.
 
Here are examples of passing queries :
Call "alter proc testProc" and remove the appropriate line.
 
Example 1: no print after insert
 
set nocount on
 insert into test_api values(getDate(), 1)
 insert into test_api values(getDate(), 2)
 select updated_date,id from test_api
 print 'Did the select'
 
 
Example 2: no insert statement
 set nocount on
 print 'About to call select'
 select updated_date,id from test_api
 print 'Did the select'
 
Example 3: no "set nocount on" statement
 insert into test_api values(getDate(), 1)
 insert into test_api values(getDate(), 2)
 print 'About to call select'
 select updated_date,id from test_api
 print 'Did the select'
 


		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  


More information about the FreeTDS mailing list