chandanperl has asked for the wisdom of the Perl Monks concerning the following question:
Dear All, I want to fetch values from stored procedure.I am calling stored procedure from perl script in window system and connecting it to sql server.while running this code it gives me error:Can't call method "Fields" on an undefined value at line $RS = $oSP->Execute(); Please help...
use Win32::OLE; $ConnStr = "DSN=dsn_name;UID=abcd;PWD=password;APP=test;WSID=Mycomp;DA +TABASE=db_name"; $Conn = Win32::OLE->new('ADODB.Connection'); $Conn->Open($ConnStr); #Get record set results from store procedure $oSP = Win32::OLE->new("ADODB.Command"); $RS = Win32::OLE->new("ADODB.Recordset"); $oSP->{'CommandText'} = "exec dbo.sp_reportBytes '%','%','%','%', '200 +9-1-1', '2010-1-1', 'Admin', '530', NULL;"; $oSP->{'CommandType'} = 4; $oSP->{'ActiveConnection'} = $Conn; $oSP->{'CommandTimeout'} = 1200000; $oSP->{'@Param1'} = $Param1; $RS = $oSP->Execute(); while (! $RS->EOF) { $value = $RS->Fields(1)->value; print "$value\n"; $RS->MoveNext; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running stored procedure through perl script
by Corion (Patriarch) on Mar 04, 2010 at 07:53 UTC | |
| |
|
Re: Running stored procedure through perl script
by desemondo (Hermit) on Mar 04, 2010 at 08:34 UTC | |
|
Re: Running stored procedure through perl script
by Anonymous Monk on Mar 04, 2010 at 07:50 UTC | |
|