0

I have a TEST.sql file that has below lines in it.

$ cat TEST.sql

create table AB (name varchar2(20));

insert into AB values ('AAA');
insert into AB values ('BBB');
commit;

I know I can execute this script by loging into DB and doing

sql> @TEST.sql

But I want to know ho to execute the script using a procedure/plsql. Provided that oracle has read access to that directory.

2 Answers 2

1

If you must do it that way, then create a dbms_scheduler job whose job_type is 'SQL_SCRIPT'. Your watchdog dbms_scheduler job can create child jobs whose job_type is 'SQL_SCRIPT'.

You can also create a dbms_scheduler job whose job_type is 'EXTERNAL_SCRIPT' and have it scour the directory for new files and launch sqlplus commands for each new script that it finds.

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

1 Comment

Thanks jeff. This helps.
0

@jeff6times7 showed you a way. Another way would be to use the UTL_FILE package and read the contents of the file, and then perform an execute immediate with those contents.

1 Comment

yes, may be I have to read each line from file and then execute it.

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.