Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Sybase Perl DBI

by Anonymous Monk
on Oct 18, 2012 at 09:06 UTC ( #999697=note: print w/replies, xml ) Need Help??

in reply to Sybase Perl DBI

You should write like this because of Lexical scoping like a fox, Variable Scoping in Perl: the basics

sub sa_details { my $dbh = shift; my @uids; $dbh->dbcmd("SELECT userid FROM user"); $dbh->dbsqlexec or die "Can't execute SQL statement:\n"; while( $dbh->dbresults != NO_MORE_RESULTS ){ while( my @row = $dbh->dbnextrow ){ push @uids, $row[0]; } } return @uids; } my @array = sa_details( Sybase::DBlib->new( "user", "passwd", "host", ) );

Or you could write

sub sa_details { my $dbh = shift; $dbh->nsql( "SELECT userid FROM user", "ARRAY" ); } my @arry = sa_details( Sybase::DBlib->new( "user", "passwd", "host", ) ); $DB_ERROR and die $DB_ERROR; ## $Sybase::DBlib::DB_ERROR and die $Sybase::DBlib::DB_ERROR;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999697]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2017-07-26 01:41 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (383 votes). Check out past polls.