Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 How do I call MSSQL stored procedures in perl?

Author  Topic 

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2008-08-05 : 10:05:59
This Perl is frustrating. I have no problems calling stored procedures in PHP. In Perl, it's like pulling teeth. I'm trying to execute a stored procedure that takes one parameter and returns a result set (i.e. table). This is what I have, and understand I'm doing line-by-line debugging:

quote:

$sql = "exec database.schema.sp_Calculate";
$sth = $dbh_2->prepare($sql);
$sth->bind_param("Num","5");
$sth->execute();



It gives me an error of "Can't bind unknown placeholder 'Num'". Before it even gets to the execution statement, it gives the aforementioned error at the bind_param statement. The procedure is supposed to look like exec database.schema.sp_Calculate @Num='5'. It works fine in T-SQL or from sqlcmd and in other languages. So, I know the procuedure works fine. It's a syntax issue with Perl that I can't, for the life of me, figure out.

I tried doing it this way, too:

quote:

my ($Col1, $Col2);
$sql = "exec database.schema.sp_Calculate \@Num='5'";
$sth = $dbh_2->prepare($sql);

$sth->execute();
$sth->bind_columns( undef, \$Col1, \$Col2 );



It stops at the bind_columns line and gives me this error:

"DBD::ODBC::st bind_columns failed: Statement has no result columns to bind (perhaps you need to successfully call execute first)"

But the stored procedure does return a valid result set and is not null. So, say the sql statement never executes successfully. Why? I have no problem writing select statements in Perl. They work fine. Why can I not get this to work?

Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-29 : 10:03:57
See
http://www.devarticles.com/c/a/SQL-Server/Executing-SQL-Server-Stored-Procedure-from-Perl/



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

joe.inom
Starting Member

9 Posts

Posted - 2008-08-31 : 00:24:32
Hey , now it is lie listen , Perl borrows features from other programming languages including C, shell scripting (sh), AWK, sed and Lisp.The language provides powerful text processing facilities without arbitrary data length limits, like the many Unix tools present at the time, making it the ideal language for manipulating text files. It is also used for graphics programming, system administration, network programming, applications that require database access and CGI programming on the Web

joe Alexender
Go to Top of Page
   

- Advertisement -