简体   繁体   English

从Oracle SQL Developer执行存储过程

[英]Executing a Stored Procedure from Oracle SQL Developer

How can I execute the below Stored Procedure? 如何执行以下存储过程?

create or replace procedure squareOf(x IN OUT NUMBER) is
begin
 x:= x*x;
end;
DECLARE
  x NUMBER := 6;
BEGIN
  squareOf(x => x );
  dbms_output.put_line( 'X: '|| x );
END;

returns 36 返回36

@Massie already mentioned one approach using anonymous block. @Massie已经提到了一种使用匿名块的方法。

Another approach is using bind variable in command line like below - 另一种方法是在命令行中使用绑定变量,如下所示:

var c number;
exec :c:= 6;
execute squareOf(:c);
print c;

Since you're asking about 'in SQL Developer' - here's the answer from the IDE perspective. 由于您在询问“在SQL Developer中”,因此这是从IDE角度来看的答案。

  1. Find your procedure in your database navigation tree. 在数据库导航树中找到您的过程。
  2. Click or double-click to open in a plsql editor 单击或双击以在plsql编辑器中打开
  3. Hit the Execute Button in the toolbar 点击工具栏中的执行按钮
  4. Supply required input values and hit OK to execute 提供所需的输入值,然后单击“确定”以执行
  5. Observe any output returned in the bottom log panel 观察底部日志面板中返回的所有输出

打开和执行您的PL / SQL过程

输出,在这种情况下,是您的IN / OUT的值X

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

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