I want to use Perl DBI to create views based on a database automatically. The related code is like the following,
my $dbh = DBI->connect( "dbi:Oracle:$database", $user_passwd );
my $Directive = q{ CREATE OR REPLACE VIEW SOME_VIEW AS SELECT * FROM ID_TABLE WHERE ID=?};
my $ID = 12345;
my $sth = $dbh->prepare($Directive);
my $rv = $sth->execute($ID);
Then I found the $rv
is always undef
after I run the code. Anything wrong I've made in the code? When I put the parameter directly into $Directive
, everything is good.
BTW, when I use some other $Directive, like "SELECT * FROM ID_TABLE WHERE ID=?", the parameter $ID could be passed in without any problem.