Home » SQL & PL/SQL » SQL & PL/SQL » Executing script files in a directory
Executing script files in a directory [message #443625] Tue, 16 February 2010 09:37 Go to next message
myaesubi
Messages: 3
Registered: February 2010
Junior Member
Hi,

Using PL/SQL I want to search inside a directory and execute the script files with a specific pattern.

I know that with @@ command I can execute a script, however when the name of the files come in a variable I don't know how to execute the script.

Here is the code for searching the files:

set serveroutput on
declare
directory2 varchar2(1024):='/home/oracle/dir';
ns varchar2(1024);
begin
SYS.DBMS_BACKUP_RESTORE.SEARCHFILES(directory2, ns);
FOR each_file IN (SELECT FNAME_KRBMSFT AS name FROM X$_KRBMSFT) LOOP
DBMS_OUTPUT.PUT_LINE(each_file.name);

--@@ each_file.name

END LOOP;
end;

I'd appreciate your advice.

Thanks,
Mohammad
Re: Executing script files in a directory [message #443629 is a reply to message #443625] Tue, 16 February 2010 10:12 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
Post Operating System (OS) name & version for DB server system.
Post results of
SELECT * from v$version

I would attack this requirement from the OS level with a simple shell script
Re: Executing script files in a directory [message #443631 is a reply to message #443625] Tue, 16 February 2010 10:25 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1/ This can only be executed by SYS and so is bad
2/ This is not documented and so is bad
3/ Search for "dirlist" here or on asktom to find a supported way to do it
4/ PL/SQL executed INSIDE PL/SQL engine and does not execute OUTSIDE scripts
5/ Read each line of the script and then execute it (in the proper way) without forgetting that PL/SQL purpose is NOT to display stuff just to compute them.

In short, you are in the wrong way to achieve what you want.

Regards
Michel

[Updated on: Tue, 16 February 2010 10:25]

Report message to a moderator

Re: Executing script files in a directory [message #443632 is a reply to message #443629] Tue, 16 February 2010 10:27 Go to previous messageGo to next message
myaesubi
Messages: 3
Registered: February 2010
Junior Member
You both are right. I'll do it with scripting.

Thanks,
Mohammad
Re: Executing script files in a directory [message #443633 is a reply to message #443632] Tue, 16 February 2010 10:28 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
Re: Executing script files in a directory [message #443634 is a reply to message #443629] Tue, 16 February 2010 10:31 Go to previous message
myaesubi
Messages: 3
Registered: February 2010
Junior Member
Thanks, as you've advised I'll solve it with scripting. I'll use PowerShell.

Regards,
Mohammad
Previous Topic: Regarding the SQL (merged 3)
Next Topic: UTL_TCP returning blank line?
Goto Forum:
  


Current Time: Thu Dec 08 22:11:29 CST 2016

Total time taken to generate the page: 0.18354 seconds