develooper Front page | perl.beginners | Postings from February 2002

array question and ODBC note

Thread Next
February 13, 2002 13:19
array question and ODBC note
Message ID:
Recently someone pointed out that it's better to use:

while( defined( my $line = <HANDLE> ))


while( my $line = <HANDLE> )

so I have been moving towards this.  I noticed that with arrays, 
such as:

while( defined( my @data = $sth->fetchrow_array()))

this does not work - @data is defined (as a zero item array?) even 
when no record is returned.  Is the correct coding:

while( defined( my @data = $sth->fetchrow_array()) && $#data > -1 )

or something else, or is this just a waste of effort since:

while( my @data = $sth->fetchrow_array())

does seem to work?

Also it took a while but we found a workaround to the ODBC DBD not 
handling return parameters from stored procedures - instead of using 
return parameters, have the stored procedure return a result set,
then use execute to get a statement handler instead of do to get 
a return value, then loop through the result set in the statement 

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About