Dear DBI-Experts,
In 'Programming the Perl DBI' i have read that its not a good idea to bind
parameters to the from-clause
of a SQL statement.
The trouble is that i have to do exactly that.
As an input i have strings $column_name and $owner and a corresponding value
$value.First,
I check dba_tables to look up the tables with this column.
my $sql =<<SQL;
select table_name,
column_name,
owner,
from dba_tables
where lower(column_name) like ||'\%'|| ? ||'\%'
SQL
my $sth=$dbh->prepare($sql);
$sth->execute($column_name);
$sth->bind_column(\$table_name,\$result_column,\$owner);
while ($sth->fetch)
{
push(@table_name,$table_name);
push(@column_name,$result_column);
push(@owner,$owner);
}
Now I want to create select statements for $value in each of the result
@table_name.
something like that:
for ($i= 0; $i<@table_name; $i++)
{
my $sql2="select * from ? where ? = ?";
my $sth=$dbh->prepare($sql2);
$sth->execute($table_name[$i],$column_name,$value);
}
Knowing that bind params wouldnt work here i have _absolutely_ no idea how to
solve that problem.
the * from $sql2 could be replaced with a string created by a function that
'chains' @result_column values
separated by commas, but even then i _know_ that prepare wont work.
is there a clue ?
Any help would be appreciated.
Michael
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
M�chten Sie mit einem Gru� antworten? http://grusskarten.yahoo.de