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: Mick Ghazey <mghazey at yahoo dot com>
Subject: dbrpcparam and DBRPCRETURN
Date: Jun 12 1998 8:35PM

I'm trying to understand dbrpcparam when used with DBRPCRETURN. The
only literature I could find on this subject was in the Visual Basic
section of SQL Server Books Online. We're using Sybase on Solaris.

The following program passes variables by reference to the getVars
subroutine. Sub getVars runs proc getVars. Notice the dummy variables
$d1,$d2,$d3,and $d4. They're used when requesting data to be returned
from the sproc. Surprisingly the data is not returned to those
variables. The data must be retrieved using $dbh->dbretdata. But the
$d1..$d4 variables must be declared, values must be assigned, and
lengths must match the values for the program to work!



--------------------------------

Snippits from the actual program

RunGetFeedInstance(\$FeedInstance,\$CharacterSet,
	           \$FormatType,\$ErrorCode,
	           $FileName);
...

sub getVars($$$$$)
{
my ($FeedInstance,$CharacterSet,$FormatType,
    $ErrorCode,$FileName) = @_;

$dbh->dbrpcinit("pc_getVars",0);

my($d1,$d2,$d3,$d4) = (0,' ',' ',0);
$dbh->dbrpcparam('@FileName',0,SYBCHAR,-1,
        length($FileName),$FileName);
$dbh->dbrpcparam('@FeedInstance',DBRPCRETURN,
	SYBFLT8,-1,-1,$d1);
$dbh->dbrpcparam('@CharacterSet',DBRPCRETURN,
	SYBCHAR,1,length $d2,$d2);
$dbh->dbrpcparam('@FormatType',DBRPCRETURN,
	SYBCHAR,1,length $d3,$d3);
$dbh->dbrpcparam('@ErrorCode',DBRPCRETURN,
	SYBINT4,1,-1,$d4);
$dbh->dbrpcsend;

...

#Get return data from Stored Proc
($$FeedInstance,$$CharacterSet,
$$FormatType,$$ErrorCode) = $dbh->dbretdata;
return;

-----------------------

CREATE PROCEDURE dbo.pc_getVars (
@FileName		char(255),
@FeedInstance		numeric(18,0)	out,
@CharacterSet		char(1)		out,
@FormatType		char(1)		out,
@ErrorCode		int		out)

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com