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 MBAY dot NET>
Subject: Re: Help using sybperl Sybase::DBLib sql routine
Date: Sep 23 1997 8:46PM

bbrown2@lindy.stanford.edu wrote:
> 
> I'm using the Sybase::DBLib routines.
> 
> I've called sql with
> 
>         $db->sql("select field1, field2 from tablename");
> 
> It returns something like:
> 
> >>>> ARRAY(0x330f14)
> >>>> ARRAY(0x330f38)
> >>>> ARRAY(0x334928)

sql() returns a reference to an array of reference to arrays...

So:

$d = $db->sql("select field1, field2 from tablename");
foreach $row (@$d) {
    $field1 = $$row[0];
    $field2 = $$row[1];
}


> 
> I thought that sql had a flag in the third field that set the kind of
> results so I tried:
> 
>         $db->sql("select field1, field2 from tablename", "", 1);
> 
> I get this:
> 
> Call sql
> Undefined subroutine &main:: called at
> /opt/perl5.003/lib/site_perl/auto/Sybase/DBlib/sql.al
> line 21,  chunk 5.
> 
> This:
> 
>         $db->sql("select field1, field2 from tablename", NULL, 1);
> 
> gives this result:
> 
> Call sql
> Undefined subroutine &main::0 called at
> /opt/perl5.003/lib/site_perl/auto/Sybase/DBlib/sql.al
> line 21,  chunk 5.

Try $db->sql($sql, undef, 1)

This will return a reference to an array of references to hashes:

$d = $db->sql($sql, undef, 1);
foreach $row (@$d) {
    $field1 = $row->{field1};
    $field2 = $row->{field2};
}

Hope this helps!

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler