简体   繁体   English

如何执行具有输出参数的存储过程

[英]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? 这个问题回答有关调用Oracle存储过程的问题: 如何执行Oracle存储过程?

However I have a procedure which takes one IN and one OUT parameter. 但是我有一个过程,需要一个IN和一个OUT参数。 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? 我在Oracle SQL Developer中的测试语法应该如何定义变量,运行存储过程并输出该变量的结果?

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? 我在Oracle SQL Developer中的测试语法应该如何定义变量,运行存储过程并输出该变量的结果?

Create a unit test. 创建一个单元测试。

  1. Go to Tools > Unit Test > Select Current Repository and follow the prompts to set up a unit test repository. 转到Tools > Unit Test > Select Current Repository然后按照提示设置单元测试存储库。
  2. Go to View > Unit Test to open the Unit Testing view. 转到View > Unit Test以打开“单元测试”视图。
  3. Right-click on tests and choose Create test . 右键单击测试,然后选择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 . 指定测试名称,然后选择Create single with dummy implementation然后单击Next
  6. Click 'Next' (you don't need any startup). 单击“下一步”(不需要任何启动)。
  7. Specify the values for the parameters then click Finish . 指定参数的值,然后单击“ Finish
  8. The test should then appear in the Unit Test view and you can right-click and select Run Test . 然后,该测试应出现在“ Unit Test视图中,您可以右键单击并选择Run Test

Oracle's documentation for unit tests is here . Oracle的单元测试文档在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何执行没有varchar的程序 - how to execute procedure which has out varchar 如何在SQL Developer中使用SQL工作表执行具有4个输入参数和60个以上输出参数的Oracle存储过程? - How to execute Oracle Stored Procedure with 4 input parameter & more than 60 Output Parameter using SQL Worksheet in SQL Developer? 如何使用TYPE作为参数调用和执行Oracle存储过程 - How to call and execute a Oracle stored procedure using TYPE as a parameter 如何使用RECORD TYPE作为OUT参数执行存储过程 - How to execute a Stored Procedure with RECORD TYPE as OUT parameter 如何获取作为数组的存储过程输出参数? - How do I get a stored procedure output parameter that is an array to work? 如何从存储过程中使用Grails中的输出参数获取返回值? - How to get return value from stored procedure with output parameter in Grails? 我们如何在存储过程中定义输出参数大小? - How can we define output parameter size in stored procedure? 如何使用Spring调用带有ref游标作为输出参数的存储过程? - How to call a stored procedure with ref cursor as an output parameter using Spring? 如何从Oracle中的存储过程检索输出参数 - How to retrieve output parameter from stored procedure in oracle 使用参考光标输出动态执行存储过程 - Dynamically execute a stored procedure with reference cursor output
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM