0

Here is my PL/SQL.

execute immediate '
create table Alex_Test2(col1 varchar2(100));
/
drop table Alex_Test2;
/
';

In the dynamic SQL, a table is created and then dropped immediately. The funny thing is that the table is successfully created and dropped but I got error.

Error starting at line 1 in command:
execute immediate '
Error report:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "; END;" when expecting one of the following:

   := . ( @ % ;
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.

Error starting at line 6 in command:
'
Error report:
Unknown Command

The SQL statements actually typed by user. I cannot avoid the symbols like ; and /. How can I fixed this problem? Or how can I bypass this error?

However, I still need to keep the log. I expect the log is just

table ALEX_TEST2 created.
table ALEX_TEST2 dropped.

Thanks!

1 Answer 1

2

You are unable to manipulate the query string before executing it? If you don't have the ability to do that then what do you have the ability to do?

Sounds like you just need to do a find and replace on the query string before running it.

Sign up to request clarification or add additional context in comments.

2 Comments

The dynamic SQL is typed by user that I cannot change it. I can control all other things. What do I need to "find and replace"?
Okay, so you are just saying you can't prevent them from entering them... but you can manipulate their input before you run it. In SQL Server I would use the replace function: msdn.microsoft.com/en-us/library/ms186862.aspx. It might be the same in your dbms, but if not just do a Google search and I'm sure you'll find it faster than it would take you to ask again and me to look it up for you and respond with the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.