1

Let's say I've got a large script and want to cut it into pieces and then load the pieces from a main script file.

The question is how to load and execute an external script using plain SQL in Oracle DBMS or PL/SQL from another script file?

1 Answer 1

3

For SQL*plus, you can use:

@filename.sql

or

@@filename.sql

Please realize that @ is a SQL*plus command - not a SQL or PL/SQL command. SO you cannot use this from inside a PL/SQL stored procedure - it would not make much sense either, as essential context like current working direcory is absent in that case.

Form inside a stored procedure, you could in principle load external code using dynamic sql, but a better way to break up a stored procedure is to break it into several smaller stored procedures. If you like you can group those togehter in a package (see http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/packages.htm#CIHIJECJ)

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

1 Comment

The latter worked for me, thank you! I'm supposed to prepare a demo in which I create a schema, populate tables with data and create a package. All this is supposed to execute from a single file - that's the main reason I wanted to slice everything.

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.