in reply to Perl::DBI - column not returned in order of SQL command

Thanks for the reply. Below are the code. My SQL statement is in the form of "select name, address, age from table". But the actual statement is simply a much longer form i.e. it has 28 columns. I tried removing the "udef" without any success. I did run execute before bindings. Btw, I also uses "$sqlexe->{NAME}$i" to get the column name and I can see that it's sequence is not the same as that of the SQL statement. iPhony
my $dbh = DBI->connect ( "dbi:Oracle:host=$ip;sid=$sd;port=1521", $id, + $pw, {RaiseError => 1, AutoCommit => 0} ); $dbh->{LongTruncOk} = 1; my $sqlexe = $dbh->prepare( $sql ); $sqlexe->execute(); $sqlexe->bind_columns ( undef, \$tempdata[0], \$tempdata[1], \$tempdat +a[2], \$tempdata[3], \$tempdata[4] ); while ( $sqlexe->fetch() ) { push @{@data}, [ $tempdata[0], $tempdata[1], $tempdata[2], $tempda +ta[3], $tempdata[4] ]; } $sqlexe->finish(); $dbh->disconnect();

Replies are listed 'Best First'.
Re^2: Perl::DBI - column not returned in order of SQL command
by Corion (Patriarch) on Dec 11, 2008 at 09:20 UTC

    This sounds to me more like an issue of DBI, or rather, DBD::Oracle then. But as you steadfastly refuse to show the SQL and the relevant data (that is, a Data::Dumper output of the first two rows fetched or something like that), we can't help you. Have you tried doing a simple ->fetchrow_array instead of binding your columns?

Re^2: Perl::DBI - column not returned in order of SQL command
by moritz (Cardinal) on Dec 11, 2008 at 09:26 UTC
    My SQL statement is in the form of "select name, address, age from table". But the actual statement is simply a much longer form i.e. it has 28 columns.

    So does the error also appear with a simple SQL statement? <op>And can you reproduce it with $sqlexe->fetchrow_array instead of bind? (If not, it's likely a problem with the parameter binding). What happens if you use references to scalars instead of references to array elements for binding?