jsk007 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
Can u pls help me tackling this issue.....

I will be recieving a set of .sql files name along with its path in an Excel file. I have to read these sql scripts name along with its path and compile it from Perl. In oracle there are two commands which helps in achieving this
Sta "filepath/filename.sql"; or @filepath/filename.sql;
both these queries when executed in oracle runs absolutely fine. But when i execute this query via the execute method DBI, it throws the following error.

@D:/coe_det.sql DBD::Oracle::st execute failed: ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute) for Statement "@D:/coe_det.sql" at deploy_db_obj.pl line 97.

Here D:/coe_det.sql is the name of my script with its path;

FYI am using Perl 5.8.8 and my code is as follows
foreach my $i (1..$#input) { $script=$input[$i][1].$input[$i][0]; my $compilation_query="\@$script"; print "$compilation_query\n"; my $sth=$db_conn_obj->prepare($compilation_query) or die "prepare +err:". $db_conn_obj->errstr; $sth->execute() or die "Cannot execute:".$sth->errstr; }


In the above code, i will have my script name along with its path in variable $script, variable $compilation_query has the sql query to be compiled i.e "@d:\coe_det.sql"

Thanks in advance.....

Replies are listed 'Best First'.
Re: Compilation of Sql Script file(.sql) from Perl
by almut (Canon) on Apr 28, 2009 at 10:44 UTC
    Sta "filepath/filename.sql"; or @filepath/filename.sql;

    As the SQL*Plus commands "STA(RT)" or "@" would run the SQL*Plus statements in the specified file, you'd (at least) have to get the contents of the file and put together a SQL query based on that... — but maybe it's easier to just use the sqlplus tool.

Re: Compilation of Sql Script file(.sql) from Perl
by Anonymous Monk on Apr 28, 2009 at 09:52 UTC
    ..invalid SQL statement ...

    That is not valid sql, that Oracle knows to execute. I've also never seen sta "foo/bar"; or @foo/bar in SQL. Its probably some shell syntaxt, not sql.