I have a .sql file which contains multiple SQL statements. I need to loop over each statement and execute them from a Perl script. The problem is that the SQL statements are multiline statements and they include comments.
Up until now, we used the sqlplus command manually. But now we need to automate it to execute every statement and capture the success or failure of each statement. If a statement fails, I need to stop executing SQL statements from the file. As far I know, this isn't possible with sqlplus; it goes on executing the remaining statements after one of the statement fails.
The .sql file looks as below....
--Add new columns to TABLE_NAME table
ALTER TABLE "DATA"."TABLE_NAME" ADD(NAME varchar2(30));
--Create new table FILE_4G_TABLE
CREATE TABLE "DATA"."FILE_4G_TABLE"
(
abc VARCHAR2(30 CHAR),
def NUMBER(38),
ghi NUMBER,
JKL VARCHAR(32)
CONSTRAINT "FILE_4G_TABLE" PRIMARY KEY ("abc")) TABLESPACE "DATA";
Someone, please guide me.