Script out many stored procedures at once?

I found lots of methods for individually scripting out stored procedures, but I'd like to know if there's a way to do many (like 100 or so) at once.
Ideally, I'd like to execute something that would save all the procedures that start with 'dev_' to the file system somewhere, then delete the dev_ SP's from the database and leave the other SPs that actually get used.
Is that possible in one step?  Does any one have a link or an idea?
Thanks in advance!!

Actually, I did slight modifications after that - here is a version that really scripts them:
set nocount on
DECLARE @Test TABLE (Id INT IDENTITY(1,1), Code varchar(max))
INSERT INTO @Test (Code)
SELECT 'IF object_ID(N''[' + schema_name(schema_id) + '].[' + Name + ']'') IS NOT NULL
DROP PROCEDURE ['+ schema_name(schema_id) +' ].[' + Name + ']' + char(13) + char(10) + 'GO' +
OBJECT_DEFINITION(OBJECT_ID) + char(13) +char(10) + 'GO' + char(13) + char(10)
from sys.procedures
where is_ms_shipped = 0
DECLARE @lnCurrent int, @lnMax int
DECLARE @LongName varchar(max)
SELECT @lnMax = MAX(Id) FROM @Test
SET @lnCurrent = 1
WHILE @lnCurrent <= @lnMax
BEGIN
SELECT @LongName = Code FROM @Test WHERE Id = @lnCurrent
WHILE @LongName <> ''
BEGIN
print LEFT(@LongName,8000)
SET @LongName = SUBSTRING(@LongName, 8001, LEN(@LongName))
END
SET @lnCurrent = @lnCurrent + 1
END
Premature optimization is the root of all evil in programming. (c) by Donald Knuth
Naomi Nosonovsky, Sr. Programmer-Analyst
My blog

Similar Messages

  • Invoking Shell Script from JAVA Stored procedure

    I am trying to invoke shell script using Java Stored procedure.
    When I run my java class outside of oracle using oracle user
    account it works but as soon as i load it into database and try
    to inovoke that class using PL/SQL wrapper it runs java class
    but is not able to invoke the shell script. Any ideas would be
    greatly appreciated.

    Pleass search the forums for "runtime" as there are many threads and examples already posted.

  • Shell script invoke from stored procedure

    Hi All,
    Can anyone tell me how to call UNIX SHELL SCRIPT from oracle stored procedure PL/SQL. Example with detailed explanation.
    Please Share the needful.
    Thanks in Advance
    Pricks

    Here, The example is given below, I want to invoke the Script which i mentioned like HERE INVOKE THE ABOVE SHELL SCRIPT in that place.
    CREATE OR REPLACE PROCEDURE spwritelog
         inFileName               VARCHAR2,
         inLogMsg               VARCHAR2,
         inLogLevel               CHAR(1),
         outRc OUT NUMBER
    AS
    tmpMsg                VARCHAR2(255);
    BEGIN
    outRc := 0;
         IF inLogLevel = 'X' THEN
              tmpMsg := "echo `date +'%Y-%m-%d %H:%M:%S'` ' " || inLogMsg || "' >> " || inFileName;
         HERE INVOKE THE ABOVE SHELL SCRIPT
         ELSIF inLogLevel = "9" THEN
              tmpMsg := "echo `date +'%Y-%m-%d %H:%M:%S'` ' " || inLogMsg || "' >> /tmp/spAllLog.err";
              HERE INVOKE THE ABOVE SHELL SCRIPT
         END IF;
    EXCEPTION
    WHEN OTHERS THEN
    outRc:=SQLCODE;
    END spwritelog;
    Please correct the code and tell.......
    please share the needful
    Edited by: 866916 on Aug 19, 2011 5:38 PM

  • Executing Unix scripts from a stored procedure

    From the sql*plus windows, I am able to execute the host command and '!sh' commands; but I need to ececute Unix scripts from a stored procedure. Hoe can I do this? Where can I get good documentation on this? Any help would be greatly appreciated!
    Thanks..

    Hi,
    U can use external procedure ( newly added feature in 8.0.3 onwards) and call any shared library. From shared library u can execute it.
    One sql command is there HOST(' '). U can run a OS command. But u can not use it in PL/SQL.
    U can call pls sql from shell !!!!!..
    Thanks...
    Boby Jose

  • Calling unix shell script from oracle stored procedure.. urgent!!!!!!!!!!!!

    Hi,
    i havea requirement where in i should be able to call my shell script through oracle stored procedure.i tried the following way..but iam unable to get the result.please find the details below.
    new.sh - my shell script - lctfile (LCTFILE) is the input pa
    v_config_file=`find $FND_TOP -name LCTFILE
    FNDLOAD apps/s0ccer@$dxbs1 0 Y DOWNLOAD $v_config_file /home/bir4163/RPT33/bin/menu.ldt MENU MENU_NAME='AR_NAVIGATE_GUI'
    if [ $? != 0 ];then
    echo "$DATE $0 FNDLOAD DOWNLOAD Failed!" | tee -a $LOG_FILE
    else
    echo "SUCCESS" | tee -a $LOG_FILE
    fi
    CREATE OR REPLACE PROCEDURE test_dbms_scheduler
    AS
    v_text VARCHAR2 (255) := 'AR_NAVIGATE_GUI';
    BEGIN
    DBMS_OUTPUT.put_line ('I am in Procedure');
    DBMS_SCHEDULER.create_job (
    job_name => 'test_dbms_scheduler',
    job_action => '/home/bir4163/RPT33/bin/new.sh',
    number_of_arguments => 1,
    job_type => 'executable',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=SECONDLY; INTERVAL=1',
    enabled => FALSE,
    auto_drop => FALSE,
    comments => 'run shell script'
    DBMS_SCHEDULER.set_job_argument_value (job_name => 'test_dbms_scheduler',
    argument_position => 1,
    argument_value => v_text);
    DBMS_SCHEDULER.enable ('test_dbms_scheduler');
    DBMS_OUTPUT.put_line ('I am back in Procedure');
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
    END;
    But iam unable to test it as i do not have permissions to access dbms_scheduler.can anybody tell me how to solve this using DBMS_PIPE with a sample code.
    please do help its very urgent
    thanks
    ramya

    Hi,
    Register your Shell Script as a concurrent program, Executable execution method "Host", then use fnd_request.submit_request to submit the program.
    Regards,
    Andries

  • Using SQL Loader script in a Stored Procedure

    Can I use SQL Loader script in a stored procedure and then execute it from a front-end appl.? The reason for this seemingly convoluted solution is that the users don't want a batch load though the records volume is quite high (around 1 mil). Other loads using ODBC connection or OLE DB seem to be inferior to SQL Loader.

    I would suggest a couple of solutions:
    1. Have a cgi script that can upload the file to the server from a web ui, then have the cgi script call the sql*loader file, and it will insert into the database.
    2. You can try to use External tables. This is avaliable in 9i and onwards. You will be able to make any sql DML on the external table.
    I would normally use sql*loader, move the data to a staging table with nologging, and paralle loading. After it has been loaded into the staging table I would process it into my main tables. Have used this approach with up to 60 million records in one load.
    You can do calls to C procedures, Pro*C procedures through PLSQL, as well as java calls, or use Java stored procedures.
    My experience is that SQL*Loader is the fastest way to load data into the database.

  • Calling script in a Stored Procedure

    I have this script and want to use it in a stored procedure but while creating it, it showed me an error:
    Error: Query : CREATE PROCEDURE test.loadXMLData() BEGIN LOAD XML LOCAL INFILE
    UserApplication.xml' INTO TABLE userapplicatio... Error Code : 1314 LOAD XML is not allowed in stored procedures
    Query:
    LOAD XML LOCAL INFILE 'UserApplication.xml'
    INTO TABLE userapplication
    ROWS IDENTIFIED BY '<Group>';
    please Help me Out for finding where i m exactly making a mistake....

    Hello,
    For me it looks like a MySQL statement, right?
    This is a Forum for Microsoft SQL Server; you better should post your question to a more related forum. =>
    http://forums.mysql.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Shell script execution from stored procedure

    I am working on a project thallt requires a shell script be executed upon the execution of a stored procedure with Oracle 10g. I have researched the matter, but there does not seem to be much out there on how to execute lines of UNIX commands by use of a stored procedure. If anybody has ever gotten this to work, any information would be appreciated. If the task is impossible, let me know, I just could not confirm that it was not something that could be done.

    A combination of things can help you out here - none of which are easy or particularily secure.
    1) From plain PL/SQL, you can call 'external procedures'. That is basically a DLL or .so that the listener can load on demand, and that external procedure (EXTPROC) can run whatever you need from the C program. C can, in turn, call a shell.
    This is fairly well documented, but be aware that 1/2 of the info is in the PL/SQL docco and the other half in the Networking docco.
    A fair bit of info is available in metalink as well - if you have access, simply search on extproc.
    2) You can call a Java stored procedure which in turn has hooks to the outside world. That will probably require a PL/SQL to Java wrapper to make it available in your environment. Oracle has been using this one successfully for a while.
    3) Write the script using UTL_FILE and have a daemon look for, and execute, the script.
    4) Since you are using 10g, use the new job scheduler. It has excellent capability to interact with the OS, and it is available as a PL/SQL package (DBMS_SCHEDULER). I find the interface a bit heavy, but that could be wrapped by a library tailored to your specific needs.
    Let us know what you decide to do in the end (and why) - it is an interesting topic.

  • How do i fire a query/Stored procedure only once

    Hi,
    I have a master frame and multiple child frames. Master frame triggers child1 frame which triggers child 2 frame etc using some common keys between the frame.
    Now each frame executes a stored procedure and then uses the Db2 cursor as a record set. However when the same frame is fired again then the stored procedure is triggered again. But i could very well use the same record set from the record set that i already have,
    In other words i need to fire the stored procedure/query only once and not every time the frame is fired.
    I just need to get the record set for each frame and then operate on the retrieved record sets.
    Is there a way to do this?
    Currently I experience serious performance issues as the stored procedures get fired repeatedly thousands of times
    Any help will be greatly appreciated
    Thanks
    anand

    I am still haveing problems so I will try and attach my program and see if you can help a little more that. It will probably be easier for you to look at this way. When you look at the diagram sequence 0 is the one the problem is in. In that sequence you will see a case structure and that is where the finite pulse train vi is. When case 1 is selected the finite pulse train will run again and again until I leave case 1. I need to have the program run the finite pulse train once and then wait and do nothing until the case is changed. The finite pulse train will be in all cases inside the case structure I just haven't done that yet, I am waiting until it works. The pulse train is used to move a stepper motor that is why running only once is im
    portant because the stepper motor is used to position something.
    Attachments:
    AMC_Eagle_Both_Inputs_Working_2.vi ‏266 KB

  • Need Example on calling a unix shell script from oracle stored procedure

    Hi
    Can anybody give example on how to call unix shell script from an Oracle stored procedure. Please give a small example on how to do this .I need this urgently please.
    Have a nice time.
    Thanks & Regards
    Jogesh

    If you are on 10g you can also use DBMS_SCHEDULER. See Re: Excute Unix command Using PL SQL

  • Java Script in a Stored Procedure

    I have a stored procedure. I use HTP Pacakge to generate the Page with HTML tags.
    I need to include a Javascript file in the stored procedure . I donno the path where the JS file resides in the Appserver meaning the context root.
    Any help in educating me the location where JS ,CSS,IMAGE files are placed
    in the appserver is most welcome.
    I am using Oracle 10g DB and Oracle 10g App server.

    The App Server has an Apache-based HTTP server. It uses the standard Apache config files - you can probably look at the $ORACLE_HOME/Apache/Apache/config/httpd.conf to find the document root.
    The $ORACLE_HOME is the App Server's Home, not the database's Home

  • Ho to find out what stored procedures and ssis packages are connecting to server(For examle: ss-cube)?

    Hello Experts, 
    Is there any efficient way to see what stored procedures and ssis packages are connecting to server ss-cube?
    Can you please help me to come across.
    Thanks in advance,
    Regards,
    Hari

    Hello Experts, 
    Is there any efficient way to see what stored procedures and ssis packages are connecting
    to server ss-cube?
    Can you please help me to come across.
    Thanks in advance,
    Regards,
    Hari

  • Script to copy all the objects within a Stored Procedure

    I am trying to copy all the objects from one database to another using Scripts. Now I need to put that script inside a Stored Procedure.
    Thanks.

    Refer this vbscript to generate all object scripts programatically,
    http://www.codeproject.com/Articles/16195/How-to-Script-Out-SQL-Server-Objects
    or
    Using SSMS
    http://msdn.microsoft.com/en-IN/library/hh245282.aspx#GenPubScriptWiz
    Regards, RSingh

  • Calling shell script from stored procedure.

    Hi Everybody,
    Could anyone tell me how to call a shell script from a stored procedure.
    Thanks,
    Vasu

    You would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
    Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
    Justin

  • Running a sql script from stored procedure

    Hi everyone!
    Has anybody tell me how to execute a sql script from a stored
    procedure!
    Thanks in advance!
    Sasa

    >
    Hi everyone!
    Has anybody tell me how to execute a .sql file from a stored
    procedure!
    Thanks in advance!
    Sasa Sorry, a .sql file!!

Maybe you are looking for

  • How do i update my apps on my iphone using itunes 11.0.0.163

    How do i update my apps on my iphone using itunes 11.0.0.163

  • Error deploying Web Service after upgrading from WL 7.0 No Service Pack to SP5

    Hello I have problem using HttpServletResposneWrapper with a ServletFilter in WLW 7.0 SP5. When I apply the filter to JWS file in Development Mode, following Exception is thrown when I access a JWS. ===================================================

  • URL from PushNotificationChannelManager cannot be found

    I'm building a Windows Phone 8.1 app that communicates with a Windows Service with SignalR. The URL I recieve from: PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync() Looks like: "http://notificationserver.microsoft.com

  • Timer in livecycle

    Hi everybody I try to get the presence of these objects when the file is opened. I use the initialize event. It works in a random way. Sometimes it's OK, sometimes it stops anywhere and sometimes it doesn't start. I assume that a pause is needed. But

  • Iphoto slideshow to idvd....with snapshot effect

    Please help....I am trying to transfer a slideshow in iphoto using the snapshot effect. My music is tied to this slideshow. When transferring to idvd, the music doesn't sync and the snapshot effect is gone. It looks like a half-hearted dvd. How can I