Sybase and Perl DBI -

Sybase and Perl DBI -

Post by Lars Markhu » Tue, 08 Apr 2003 00:20:06



Hi

I'm new to Perl DBI and wonder if someone has got a code example of how one
retreives the return value from a Sybase stored procedure execute which
produces a result set and a return value?

create procedure sp_any_proc as
select ...

In Perl:

$sth->prepare("exec sp_any_proc");
$sth->execute();

and then somehow get the return value?

I've read the perldoc DBD::Sybase and Perl DBI book on O'Riley, but I'm
still stuck.

Thanks ... Lars Markhus

 
 
 

Sybase and Perl DBI -

Post by Wolfgang Loc » Tue, 08 Apr 2003 18:52:14


Quote:> In Perl:

> $sth->prepare("exec sp_any_proc");
> $sth->execute();

> and then somehow get the return value?

my $sth = $dbh->prepare("exec sp_any_proc") or return;
my $rowCount = $sth->execute or return;


   ...
Quote:}

$sth->finish;

Hope this helps,
Wolfgang

 
 
 

Sybase and Perl DBI -

Post by Michael Pepple » Wed, 09 Apr 2003 01:02:03



> Hi

> I'm new to Perl DBI and wonder if someone has got a code example of how
> one retreives the return value from a Sybase stored procedure execute
> which produces a result set and a return value?

> create procedure sp_any_proc as
> select ...

> In Perl:

> $sth->prepare("exec sp_any_proc");
> $sth->execute();

> and then somehow get the return value?

The other poster gave you the simple solution that should work in your
case.

However here is the complete solution:

use DBI;
use DBD::Sybase;   # for the CS_*_RESULT symbols.
...
$sth = $dbh->prepare("exec ...");
$sth->execute;
do {
    while($data = $sth->fetch) {
       if($sth->{syb_result_type} == CS_STATUS_RESULT) {
           $return_status = $data->[0];
       } else {
            ... process other types of results ...
       }
    }

Quote:} while($sth->{syb_more_results});

Michael
--
Michael Peppler                              Data Migrations, Inc.

Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
 
 
 

Sybase and Perl DBI -

Post by Lars Markhu » Thu, 10 Apr 2003 03:31:51


Thank you. That was exactly what I needed.

Lars Markhus



> > Hi

> > I'm new to Perl DBI and wonder if someone has got a code example of how
> > one retreives the return value from a Sybase stored procedure execute
> > which produces a result set and a return value?

> > create procedure sp_any_proc as
> > select ...

> > In Perl:

> > $sth->prepare("exec sp_any_proc");
> > $sth->execute();

> > and then somehow get the return value?

> The other poster gave you the simple solution that should work in your
> case.

> However here is the complete solution:

> use DBI;
> use DBD::Sybase;   # for the CS_*_RESULT symbols.
> ...
> $sth = $dbh->prepare("exec ...");
> $sth->execute;
> do {
>     while($data = $sth->fetch) {
>        if($sth->{syb_result_type} == CS_STATUS_RESULT) {
>            $return_status = $data->[0];
>        } else {
>             ... process other types of results ...
>        }
>     }
> } while($sth->{syb_more_results});

> Michael
> --
> Michael Peppler                              Data Migrations, Inc.

> Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
> long term contract positions - http://www.mbay.net/~mpeppler/resume.html

 
 
 

1. Connecting to Sybase using Perl DBI

Greetings,
I am writing a perl script for Sun Solaris that accesses a Sybase
database outside our facility. Therefore, where I must specify the
server in DBI::connect(), I need xxx.xxx.edu.  In addition, I must
connect to a specific port.  Here is what I am trying:

use DBI;
# use DBD::Sybase;
$ENV{"SYBASE"} = "/usr/local/apps/sybase";
$ENV{"LANG"} = "";  # used to be C and wouldn't even get to connect()
$sybh = DBI->connect("dbi:Sybase:server=xxx.xxx.edu:9999", $user, $pass)
|| die;
print ($sybh);  # only way to get response from the program about
connect()
$sybh->disconnect;

I have set the locale , etc. and fixed initial problems with finding the
drivers.  It would only start the connect() when DBD::Sybase was
commented out (as it is above).  Here is the error:

DBI->connect failed: OpenClient message: LAYER = (5) ORIGIN = (3)
SEVERITY = (4) NUMBER = (3)
Message String: ct_connect(): network packet layer: internal net library
error: Specified server name attribute could not be found at dbitest.pl
line 22

Do I need to include DBD::Sybase?  If so, how do I do so & to what
directory under /usr/local/apps/sybase to I make the $ENV{"SYBASE"}?
Also, am I correctly specifying the remote host & port (I have also
tried omitting the port no. and also changing the : to a ,)?

Thanks in advance.

--
Kyle Wright


San Diego Supercomputing Center
UCSD

2. setting up sybmail

3. Perl DBI and Sybase

4. Populating first line of big database - Speed very slow!?

5. Perl Sybase DBD/DBI problem.

6. Automatic datamodel generation possible?

7. Perl CGI - DBI with Sybase Question

8. Bulk Logged Recovery Model Questions

9. perl DBD, perl DBI programming

10. Remote Procedure output using Perl DBI:ODBC

11. Problem with PERL/DBI/mysql

12. Perl, DBI, ODBC Column Types Don't Bind

13. perl - using mssql without module DBI::ODBC