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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Calling a Stored Procedure with 30 parameters
Date: Feb 17 2000 6:44PM

wlius writes:
 > >Wei Liu writes:
 > > > 	I'm using the CTlib for calling a stored procedure with 30
 > > > parameters.  All these 30 params are of the same type and passed from an
 > > > array of strings.  Is there any way that I can use a loop to go thru each
 > > > param instead of sending the param via $dbh individually 30 times?  Thanks!
 > >
 > >How do you set the params at the moment?
 > >
 > >Do you use the ct_param() call?
 > 
 > 
 > Yes, indeed like this:
 > 
 > $d->ct_param({name => '@arg_str1',
 >            datatype => CS_CHAR_TYPE,
 >              status => CS_INPUTVALUE,
 >               value => $arg_str[0],
 >           indicator => CS_UNUSED});
 > 
 > 
 > Now that I have @arg_str1 to @arg_str30 and they are the 30 elements of an
 > array @arg_str.  What I am thinking is that using the above ct_param()
 > individually 30 times for these 30 params, though worked perfectly, may
 > seem a bit too much repetition.  I have tried to use a loop by omitting the
 > 'name' in above ct_param() call but only got an error msg.

for($i = 1; $i <= @arg_str; ++$i) {
    $d->ct_param({name => "\@arg_str$i",
             datatype => CS_CHAR_TYPE,
               status => CS_INPUTVALUE,
                value => $arg_str[$i-1],
            indicator => CS_UNUSED});
}

should do the trick...

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com