If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > how to create execute statement within another execute statement in perl?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-10, 23:00
beanryu beanryu is offline
Registered User
 
Join Date: Aug 2010
Posts: 1
how to create execute statement within another execute statement in perl?

Hello there,

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:
Code:
my $create_table_proc = $dbh->prepare("
        if (not exists(select name from sysobjects where name = 'create_table_proc'))
        begin
                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)')
                ')
        end
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.

Thanx in advance.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On