Simple utility sub to call a Sybase stored procedure and getting the output parameter values.

Call like this:

my $raOutput = executeProcedure($oDbConfig, q{ declare @default_type int, @default_language_id char(2) exec get_config @default_type output, @default_language_id out +put }) or die("Could not exec SP\n");

/J

=head2 executeProcedure($oDbh, $sql) Execute the SP defined by $sql in $oDbh, and return an array ref with the output parameters. Return undef on failure. Die on db failure. =cut sub executeProcedure { my $self = shift; my $pkg = ref($self); my ($oDbh, $sql) = @_; my $oSth = $oDbh->prepare($sql) or die("Could not prepare SQL ($sq +l)\n"); $oSth->execute() or die("Could not execute SQL ($sql)\n"); my $raRowOutput = undef; do { while(my $raRow = $oSth->fetch()) { if($oSth->{syb_result_type} == 4042) { # it's a PARAM resu +lt $raRowOutput = $raRow; last; } } } while($oSth->{syb_more_results}); return($raRowOutput); }

Replies are listed 'Best First'.