Hi,

Just installed SQL Service Pack 3 on some of our systems and now the cursor 
behavior has changed.  When I run the below SQL statement in SQL Query 
Analyzer I get the correct output; however, DBI::ODBC returns the following 
error:

Error Detail: [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find 
prepared statement with handle 0. (SQL-37000)(DBD: st_execute/SQLExecute 
err=-1): : No such file or directory

Below is a copy of SQL statement.  Any assistance would be greatly appreciated.

Thanks,

Jon

################ SQL ###########################

set nocount on
        
        DECLARE search_cursor CURSOR LOCAL SCROLL OPTIMISTIC FOR
        
        select
                ID as EntryID,
                Name as FullName,
                EntryCode
        FROM Entry
        $where
        order by EntryCode $asc

        create table #temp_table
        (
                ORD int NOT NULL ,
                Results int NULL ,
                EntryID int NULL ,
                FullName varchar (200) NULL ,
                EntryCode varchar (12) NULL
        )

        OPEN search_cursor

        insert into #temp_table (ord,results) values (0,\@\@CURSOR_ROWS)

        declare
                \@i int,
                \@id int,
                \@fn varchar (200),
                \@ec varchar (12)
        
        select \@i = 0

        FETCH ABSOLUTE $st FROM search_cursor INTO \@id,\@fn,\@ec
        if ( \@\@FETCH_STATUS = 0 )
        begin
                select \@i = \@i + 1
                insert into #temp_table values (\@i,null,\@id,\@fn,\@ec)
        end

        while ( (\@i < $ps) and (\@\@FETCH_STATUS = 0) )
        begin
                FETCH NEXT FROM search_cursor INTO \@id,\@fn,\@ec
                if ( \@\@FETCH_STATUS = 0 )
                begin
                        select \@i = \@i + 1
                        insert into #temp_table values (\@i,null,\@id,\@fn,\@ec)
                end
        end

        select * from #temp_table order by ord

Reply via email to