Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Sybperl - Reference Question
Date: Mar 27 2000 2:35PM writes:
 > Hi,
 > I have asked this question to all four user groups listed in Massachusetts
 > without a single reply.

You should probably have directed this question to the sybperl mailing 
list (

[discussing using dbnextrow(1,1) instead of dbnextrow(0,0) ]

 >      I understand the first value of dbnextrow but do not understand of the
 > second value except it  returns a reference.
 > What is the advantage of using this ?  While ($ref = $dbh->dbnextrow(1,1))
 > since we are only writing the column/s value with a newline: Print MOO
 > $$ref{claim_Status_file}, ?\n?;

Passing a first param of 1 to dbnextrow makes it return a hash, keyed
on the column names. Although this slows the process down a bit (the
array that is returned is by definition twice as large, with the key,
value pairs) this makes writing the rest of the code very simple, as
you don't have to remember where in the array a certain column is
located (ie you say $data{claim_status_file} instead of $data[3]
[assuming claim_status_file is the fourth column of the output]).

The second argument to dbnextrow() is a performance enhacement that is 
valid in certain cases. What this does is to pre-allocate an array,
and the fill the *sam* array for each iteration that calls
dbnextrow(), returning a reference to this array.

This will speed up any fetch loop where the data is immediately
processed in the loop, which appears to be your case.

Michael Peppler         -||-  Data Migrations Inc.    -||-
Int. Sybase User Group  -||-
Sybase on Linux mailing list: