简体   繁体   中英

How to execute a stored procedure which has an output parameter

This question answers about calling an Oracle stored procedure: How to execute an oracle stored procedure?

However I have a procedure which takes one IN and one OUT parameter. What should my test syntax in Oracle SQL Developer look like to define a variable, run a stored procedure, and output the result of that variable?

I'm trying this but declaring the variable gives me an error:

begin
xyz MY_TABLE.EMAIL_ADDRESS%TYPE := NULL;
myPackage.GetEmailForId('12345',xyz);
end;
declare
    xyz MY_TABLE.EMAIL_ADDRESS%TYPE; 
begin 
    myPackage.GetEmailForId('12345',xyz);
    dbms_output.put_line(xyz);
end;

What should my test syntax in Oracle SQL Developer look like to define a variable, run a stored procedure, and output the result of that variable?

Create a unit test.

  1. Go to Tools > Unit Test > Select Current Repository and follow the prompts to set up a unit test repository.
  2. Go to View > Unit Test to open the Unit Testing view.
  3. Right-click on tests and choose Create test .
  4. Choose the connection and then pick the procedure you want to test.
  5. Specify the test name and select Create single with dummy implementation then click Next .
  6. Click 'Next' (you don't need any startup).
  7. Specify the values for the parameters then click Finish .
  8. The test should then appear in the Unit Test view and you can right-click and select Run Test .

Oracle's documentation for unit tests is here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM