Thursday, January 29, 2015

Command Line connect to Oracle DB and create a new stored PL/SQL procedure


1. Connect to Oracle DB using the following command:

sqlplus username@connectidentifier

2. Create a new TEST procedure using the following code:

CREATE OR REPLACE PROCEDURE PROC AS
BEGIN
DBMS_OUTPUT.PUT_LINE('TEST');
END;
/

3. Run the procedure using the following command:

exec TEST();

NOTE: If there is no output, run the "SET SERVEROUTPUT ON" command

4. You can test if the procedure was added by querying the ALL_OBJECTS table:

select * from ALL_OBJECTS where OBJECT_TYPE IN ('PROCEDURE')

5. Remove the procedure using the following command:

drop PROCEDURE USER.TEST

1 comment:

  1. It was really a nice post and I was really impressed by reading this
    AWS Online Training

    ReplyDelete