Unanswered: how to create execute statement within another execute statement in perl?
I am trying to write a query that checks whether a stored procedure exists and creates it if it doesn't already exists. The stored procedure will than checks whether a table exists and creates it if it does not exists.
I am trying to do this using DBD:ybase in perl and I want to pass the name of the table I want to create to the query from a perl variable in the following form my_proc->execute($table_name);
So far, this is what I've written in my perl script:
my $create_table_proc = $dbh->prepare("
if (not exists(select name from sysobjects where name = 'create_table_proc'))
exec('create proc create_table_proc \@table_name varchar(20) as
if (not exists(select name from sysobjects where name = \@table_name))
exec('create table ' + \@table_name + '(a int)')
But I am getting the error:
DBD:ybase::st execute failed: Server message number=156 severity=15 state=2 line=6 server=TESTSERVER text=Incorrect syntax near the keyword 'create'.
Server message number=102 severity=15 state=1 line=6 server=TESTSERVER text=Incorrect syntax near '('.
at test.pl line 31.
I've tried various combination of escaping, I am wondering if Sybase allows execute statement within another execute statement.