Hello Jeff,
> I can't help unless I see the code that caused the error. Please show
> me the prepare statement (including the full SQL) for the line that
> caused the error.
Thanks for your time. Sorry, I was using a previous version of
SQL::Statement. Actually I had installed all the required modules through
the CPAN, and the latest there is still pointing to a older version of
SQL::Statement. Therefore I manually installed the latest version (1.004)
of SQL::Statement.
The latest module versions I am working with are:
perl => 5.6.0
DBI => 1.21
DBD::CSV => 0.2002
DBD::File => 0.2001
SQL::Statement => 1.004
After this I am not even able to get output for simple SQL's. The
following script is giving me no results. Please correct me if anything is
wrong:
=====================================[Start Script]
==========================================
use DBI;
DBI->trace(1, "DBI_trace.log");
my $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\|}, { PrintError => 0,
RaiseError=> 0 });
$dbh->{'csv_tables'}->{'tab1'} = { 'file' => 'info.csv'};
$dbh->{'csv_tables'}->{'tab2'} = { 'file' => 'info2.csv'};
sub executeSQL( $ ) {
my $sqlStat = shift(@_);
my $sth = $dbh->prepare($sqlStat) or die("Unable to prepare SQL: "
.. $dbh->errstr());
$sth->execute() or die("Unable to prepare SQL: " . $dbh->errstr());
my $count;
while ( my $Fields = $sth->fetchrow_arrayref() ) {
$count++;
if ( $DBI::err ) {
die("Unable to prepare SQL: " . $dbh->errstr());
}
print "$count => ", join(", ", @{$Fields}), "\n";
}
print "\n\n";
}
executeSQL("SELECT * FROM tab1");
#executeSQL("SELECT tab1.* FROM tab1, tab2 WHERE tab1.col1 = tab2.col2");
=====================================[End Script]
=============================================
And these are the two csv files I am using:
=====================================[Start info.csv]
==========================================
col1|col2|col3|
test1|test12|test13|
test2|test22|test23|
test3|test32|test33|
test4|test42|test43|
test5|test52|test53|
test6|test62|test63|
test7|test72|test73|
test8|test82|test83|
=====================================[End info.csv]
============================================
=====================================[Start info2.csv]
==========================================
col1|col2|col3|
test1|test12|test13|
test2|test22|test23|
test3|test32|test33|
test4|test42|test43|
test5|test52|test53|
test6|test62|test63|
test7|test72|test73|
test8|test82|test83|
=====================================[End info2.csv]
===========================================
And the following is the DBI trace output for trace level 1:
=====================================[Start DBI Trace]
==========================================
DBI 1.21-nothread dispatch trace level set to 1
-> DBI->connect(DBI:CSV:csv_sep_char=\|, HASH(0x80ea6a0), ****)
-> DBI->install_driver(CSV) for linux perl=5.006 pid=28729 ruid=711
euid=711
install_driver: DBD::CSV version 0.2002 loaded from
/usr/local/perl/5.6.0/site_lib/DBD/CSV.pm
<- install_driver= DBI::dr=HASH(0x8172408)
<- default_user= ( HASH(0x80ea6a0)2keys undef ) [2 items] at DBI.pm
line 468
<- STORE('f_dir' '.' ...)= 1 at File.pm line 94
<- STORE('csv_sep_char' '|' ...)= 1 at File.pm line 105
<- FETCH= undef at CSV.pm line 77
<- STORE('csv_tables' HASH(0x834e068) ...)= 1 at CSV.pm line 77
<- connect= DBI::db=HASH(0x81466e4) at DBI.pm line 471
<- STORE('PrintError' 1 ...)= 1 at DBI.pm line 513
<- STORE('AutoCommit' 1 ...)= 1 at DBI.pm line 513
<- connect= DBI::db=HASH(0x81466e4)
<- FETCH= HASH(0x834e068)0keys ('csv_tables' from cache) at CSV.pl line
6
<- FETCH= HASH(0x834e068)1keys ('csv_tables' from cache) at CSV.pl line
7
<- FETCH= 'DBD::CSV::st' ('ImplementorClass' from cache) at File.pm
line 161
3 <- FETCH= ( '' ) [1 items] at CSV.pm line 91
3 <- FETCH= ( 1 ) [1 items] at CSV.pm line 91
3 <- FETCH= undef at CSV.pm line 96
2 <- csv_cache_sql_parser_object= SQL::Parser=HASH(0x81d744c) at File.pm
line 170
<- STORE('f_stmt' DBD::CSV::Statement=HASH(0x8142ef4) ...)= 1 at
File.pm line 182
<- STORE('f_params' ARRAY(0x837f6a0) ...)= 1 at File.pm line 183
<- STORE('NUM_OF_PARAMS' 0 ...)= 1 at File.pm line 184
<- prepare('SELECT * FROM tab1' CODE)= DBI::st=HASH(0x834e038) at
CSV.pl line 11
<- FETCH= HASH(0x834e068)2keys ('csv_tables' from cache) at CSV.pm line
119
<- FETCH= undef at CSV.pm line 124
<- FETCH= undef at CSV.pm line 126
<- FETCH= undef at CSV.pm line 129
2 <- FETCH= '|' ('csv_sep_char' from cache) at DBI.pm line 1015
<- EXISTS= 1 at CSV.pm line 130
<- FETCH= '|' ('csv_sep_char' from cache) at CSV.pm line 130
2 <- FETCH= undef at DBI.pm line 1015
<- EXISTS= '' at CSV.pm line 133
2 <- FETCH= undef at DBI.pm line 1015
<- EXISTS= '' at CSV.pm line 137
<- FETCH= '.' ('f_dir' from cache) at Unix.pm line 57
2 <- FETCH= 0 at File.pm line 386
2 <- STORE('NUM_OF_FIELDS' 4 ...)= 1 at File.pm line 386
<- execute(CODE)= '0E0' at CSV.pl line 12
<- fetchrow_arrayref= undef row-1 at CSV.pl line 14
<- DESTROY= undef
<- disconnect_all= undef at DBI.pm line 533
<- DESTROY= undef during global destruction
<- DESTROY= undef during global destruction
=====================================[End DBI Trace]
==========================================
Regards,
Sumit.
<<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>>
If everything seems under control, you're just not going fast enough.
<<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>>
i2 Technologies Software Pvt. Ltd.