Hi all,
I am trying to execute a SQL statement with multiple lines with EXEC in a stored procedure, but I cannot get it to work.
As an example, my procedure should look as follows:
v_string VARCHAR (5000);
/********* Begin Procedure Script ************/
BEGIN
v_string :=
'DROP TABLE ICV_HCV.TEST;
CREATE TABLE ICV_HCV.TEST(A INT)';
EXEC :v_string;
END;
/********* End Procedure Script ************/
The activation of the procedure works fine. However, I always get an error when calling the procedure.
So I tried different ways to create v_string.
1) I added a line break after the semicolon of the first statement:
v_string :=
'DROP TABLE ICV_HCV.TEST; ' || char(13) || char(10) ||
'CREATE TABLE ICV_HCV.TEST(A INT)';
When I do SELECT :v_string from dummy it shows the statement correctly with a line break, but the procedure call does not work anyway.
2) I left the semicolon away. Then I got the error 'incorrect syntac near "CREATE".
Is there any way to execute multline SQL statements in one EXEC call?
Thanks in advance!