I tried your query w/DBI, and it seems to work ok. Perhaps your problem is
in your connect() parameters. What you have resembles the old style
parameters,
which I don't think supports the attributes at the end. read the perldocs
for
DBI and use:
connect('dbi:<driver>:<dbname>', 'user', 'passwd', {attributes...});

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 18, 2001 1:13 PM
To: [EMAIL PROTECTED]
Subject: Generating queries within sql - no results?


Hi all,

Perl 5.6, DBI 1.14, DBD-Oracle 1.06

I'm trying to generate a series of sql statements within sql using a command
like the one below.  Unfortunately, while I get results back with a tool
like TOAD, I get nothing back within my Perl script.  What have I done
wrong?

my $query = "SELECT 'select count(*) from '||table_name||' where
'||column_name||' = something;'
   from user_tab_columns
   order by 1";

my $dbh = DBI->connect(DB,USER,PASSWD,DRIVER,{RaiseError=>1});
my $sth = $dbh->prepare($query);
$sth->execute();

while( my @array = $sth->fetchrow_array() ){
   print "found: ", @array;  # Should just be one column
}

$sth->finish();
$dbh->disconnect();

Thanks in advance.

Regards,

Daniel Berger

Reply via email to