PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Tom Wilson <73123 dot 1360 at compuserve dot com>
Subject: RE: Executing stored procedures with parameters
Date: Mar 20 1996 4:11AM

>>I want to execute a stored procedure that
>>has parameters.  How would I do that?

There are 2 ways to do it.  The most efficient is to use a remote procedure
call.



$dbh->dbrpcinit("test_proc", 0);
$in='some stuff';
$dbh->dbrpcparam("\@in",0,SYBCHAR,-1,length($in),$in);
$dbh->dbrpcparam("\@out", DBRPCRETURN, SYBINT4, -1, -1, 0) ;
$dbh->dbrpcsend ;
@dat=$dbh->dbretdata;
print ("parms= ",@dat,"\n");

The other way is to execute the stored procedure as a normal SQL command:
Note that here you have to declare a variable (@junk) for the exec even though
it does nothing.

$dbh->dbcmd("declare \@junk int\n");
$dbh->dbcmd("exec test_proc \@in='some stuff',\@out=\@junk output");
$dbh->dbsqlexec;
@dat=$dbh->dbretdata;
print ("parms= ",@dat,"\n");