Oracle SQL Developer – How to Update Procedure via .sql Script

oracleoracle-sql-developer

I need to update a Oracle procedure via a .sql script. I know the procedure works because it is currently running on our server, but I need to update the procedure on a client's box.

I need to be able to hand them a .sql script which they will open and execute with Oracle SQL Developer, which will update the procedure, but when I try to create the .sql file and run the .sql file it fails, because it's trying to run the procedure.

I don't want the procedure to be run, but rather be created or replaced with the following updated procedure:

    CREATE OR REPLACE PROCEDURE updateDBUSER(
         p_userid IN DBUSER.USER_ID%TYPE,
         p_username IN DBUSER.USERNAME%TYPE)
    IS
    BEGIN

      UPDATE DBUSER SET USERNAME = p_username where USER_ID = p_userid;

      COMMIT;

    END;

Best Answer

Just save the ddl for the procedure. This can be done using sql-developer 'save to file'. Tell the client to start sql-developer, connect to the schema where the code should be written and have them run the script using 'start' or the equivalent for start '@' script_name The sql script should be located in the directory defined in the preferences for Database>Worksheet>'select default path to look for scripts'

@your_script

or

start your_script

It works from the worksheet, very similar to sql*plus.