You can still use placeholders in the do statement
$dbh->do($sql,undef,$id);For queries without placeholders, either create another type with a different sub
for my $id (@id){ my @query = ( [1,"DECLARE GLOBAL TEMPORARY TABLE SESSION.temp SELECT name,id FROM mytable WHERE id = ? ON COMMIT PRESERVE ROWS WITH NORECOVERY"], [3,"SELECT name FROM SESSION.temp WHERE salary >= 1","csvfile2_$id.csv"], [2,"SELECT id FROM mytable WHERE id = ? AND salary >= 1","csvfile1_$id.csv",$id], ); for (@query){ my ($type,$sql,$filename) = @$_; if ($type == 1){ $dbh->do($sql,undef,$id); } elsif ($type == 2){ run_query($sql,$filename,$id); } elsif ($type == 3){ run_query_noparam($sql,$filename); } } }
or amend the existing run_query sub to check for existence of parameter
pojif (defined $id){ print "Running $sql for $id\n"; $sth->execute($id); } else { print "Running $sql (no parameters)\n"; $sth->execute(); }
In reply to Re^6: Multiple queries on DBI corresponding to multiple csv files?
by poj
in thread Multiple queries on DBI corresponding to multiple csv files?
by jtech
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |