1

Currently I'm making sort of SQL command line interface for web-based application. It should act roughly like sqlPlus. I have encountered a problem how to execute sql's. They can be both as SQL and/or PL/SQL.

First way I thought that I can split them (by ';' or ';/') and detect separately if it's sql select or delete/update/insert or pl/sql.

Now I cant find for PL/SQL Backus–Naur Form to make regexp. May be there exists easier way?

Generally, What is the best way to make such logic ?

TIA

2 Answers 2

2

I think the best way is to use ANTLR which have a PLSQL grammar. You can generate code for java and other languages.

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

Comments

0

Use regexp to separate SQL statement and PLSQL in a sql script is almost impossible.

declare
begin
select sysdate from dual;

dbms.output('hello');
end;
/

Do you have any ideas how to recognize such a simple PLSQL code using regexp. A SQL Parser is what you need to achieve this, here is an article that may helpful.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.