Home » SQL & PL/SQL » SQL & PL/SQL » Running sql script inside another sql script
icon5.gif  Running sql script inside another sql script [message #206930] Sat, 02 December 2006 07:44 Go to next message
Dodge
Messages: 10
Registered: November 2006
Location: Slovenia
Junior Member
Hi everyone...
i was wondering...is there any way to run sql scripti from in another sql script...basically i want to like run some .sql file (script) from another .sql file.

Thnx.
Re: Running sql script inside another sql script [message #206950 is a reply to message #206930] Sat, 02 December 2006 11:28 Go to previous messageGo to next message
Littlefoot
Messages: 20900
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Sure. No problem.
REM A.SQL
select 'This is A script' from dual;

@b.sql
REM B.SQL
select 'This is B script' from dual;
SQL> @a

'THISISASCRIPT'
----------------
This is A script


'THISISBSCRIPT'
----------------
This is B script

SQL>

Re: Running sql script inside another sql script [message #206951 is a reply to message #206930] Sat, 02 December 2006 11:29 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You can do that the same way you start a sql-script in sqlplus:
use @ or start.
Re: Running sql script inside another sql script [message #206967 is a reply to message #206930] Sat, 02 December 2006 15:01 Go to previous messageGo to next message
Dodge
Messages: 10
Registered: November 2006
Location: Slovenia
Junior Member
So if i understand u correctly its something like:
(if i execute sql script in sql plus)
sql>EXEC @mySQLscriptFile.sql; (?)

Excepti i can simply write this in another .sql file and it should work(?)
Well i ll try it and i ll se how it goes...

Thnx everyone for ur help!
Re: Running sql script inside another sql script [message #206968 is a reply to message #206967] Sat, 02 December 2006 15:29 Go to previous messageGo to next message
Littlefoot
Messages: 20900
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Not really. You'd use EXEC(UTE) if you want to run a stored procedure. To run an SQL script (a file on your hard disk), you'd use @ sign.

SQL> @run_sql_script.sql
SQL> EXECUTE my_stored_procedure;
Re: Running sql script inside another sql script [message #207004 is a reply to message #206967] Sun, 03 December 2006 13:15 Go to previous message
Dodge
Messages: 10
Registered: November 2006
Location: Slovenia
Junior Member
Ohh i see...thanku your very much!

P.S.
I tried it and it works ... thnx Thumbs Up

[Updated on: Sun, 03 December 2006 13:21]

Report message to a moderator

Previous Topic: get/create script for existing DB
Next Topic: ANSI Joins
Goto Forum:
  


Current Time: Wed Dec 07 16:43:03 CST 2016

Total time taken to generate the page: 0.08965 seconds