“Cursor type changed” error on Perl OLE32 MSSQL dateadd function results

偶尔善良 提交于 2019-12-20 05:57:25

问题


The following sql "select DATEADD(day, DATEDIFF(day, 2, GETDATE()), '20:00:00') as A" runs perfectly fine in Microsoft sql query.

However in perl, it complains with the following error "Description: [Microsoft][ODBC SQL Server Driver]Cursor type changed".

I double checked and my code can run select and update statements with no issues so I am a bit stumbled about the cursor error.

Note that I have not included my connection string but have illustrated that I am using win32::OLE.

use Win32::OLE;

$conn->{ConnectionString} = "...";
$conn->open; # open connection to the DB 
$state = $conn ->state; #1 means connected   
if($state  ne "1"){...

$mssql_select = "select  DATEADD(day, DATEDIFF(day, 2, GETDATE()), '20:00:00')
as A";
$rs->Open( $mssql_select, $conn);  
my $error_collection = $conn->Errors();
my $ecount = $error_collection->Count;
my ($is_message, $real_error_found);
foreach my $error (in $error_collection)
{       
    #output error statements
    $is_message = ($error->{SQLState} eq "01000" && $error->{NativeError}==0);
    $real_error_found=1 unless $is_message;
    $status =  "ERROR # " . $error->{Number}
    . "\n Description: " . $error->{Description}
    . "\nSource: " . $error->{Source} . "\n";
} 

Results in "Description: [Microsoft][ODBC SQL Server Driver]Cursor type changed".

Any brainstormnig ideas the group can provide would be appreciated.

I figured it out, see below


回答1:


Solved it, turns out this is just a warning, sql server does not know what type of cursor will be returned, the results actually get returned. See http://social.msdn.microsoft.com/Forums/sqlserver/en-US/e15141e7-3084-487d-a60f-47afac046a55/odbcsql-cursor-error



来源:https://stackoverflow.com/questions/20436426/cursor-type-changed-error-on-perl-ole32-mssql-dateadd-function-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!