I have Oracle DB 11g Enterprise Edition and I want to execute sql script from my java code.
I am reading this sql script from a .sql file and the script contains statements such as create table
, create type
, alter table
, drop type
, drop procedure
, insert into
as well as pl/sql blocks with begin
and end
and all such constructs.
My question is, how to separate out individual sql statements for execution from java code? In MS SQL I could simply separate these sql statements by GO
keyword, whereas in Oracle db there is no such separator. So normally what is used as separator in Oracle db scripts?
As an exmple say I have following create trigger block in my sql script along with other sql statements. Here I have semicolons which I can not consider as the SQL Statement terminating charter (PL/SQL block can itself contain multiple semicolon-separated statements). Which means I can not use ;
similar to GO
(in MS SQL).
CREATE OR REPLACE TRIGGER SQLVersionHistory_SeqNum_TRG
BEFORE INSERT
ON SQLVersionHistory
FOR EACH ROW
BEGIN
:NEW.SequenceNumber := SQLVersionHistory_SeqNum.NEXTVAL;
END;