16 December 2010

Run a DB Procedure with PL/SQL in the DB

For Java originated ADF developers

Sometimes we need to run a PROC in DB to check if it works there. Below is a way.

Let's Call a PROC with 1st 2 params are IN and the 3rd is IN/OUT



code

--enable DBMS_OUTPUT
SET SERVEROUTPUT ON
DECLARE
  --Declare vars
  MY_NUM_VAR NUMBER;
  MY_STRING_VAR VARCHAR2(77);
  MY_DATE_VAR DATE;
BEGIN
  --set vars
  MY_NUM_VAR :=7; NUMBER;
  MY_STRING_VAR:='My Lucky Number;
  MY_DATE_VAR DATE:=NULL;

  --call the PROC. 1st 2 params are IN and the 3rd is IN/OUT
  MY_SCHEAMA.MY_PACKAGE.MY_PROCEDURE ( MY_NUM_VAR, MY_STRING_VAR, MY_DATE_VAR);
  
  --Print the var
  DBMS_OUTPUT.PUT_LINE(MY_DATE_VAR);
  --In case you want to commit
  --COMMIT;
END;

No comments:

Post a Comment

You might also like:

Related Posts Plugin for WordPress, Blogger...