如何在 SQL Developer 中运行以下 Oracle exec 语句?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6178930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:49:59  来源:igfitidea点击:

How to run the following Oracle exec statements in SQL Developer?

sqloracle

提问by Oh Chin Boon

I have came across these statements which are supposed to be run in Oracle, however I am not sure how these statements should be run. Tried running them as SQL but doesn't work.

我遇到过这些应该在 Oracle 中运行的语句,但是我不确定这些语句应该如何运行。尝试将它们作为 SQL 运行但不起作用。

variable output1 NUMBER;
variable output2 VARCHAR2(100);

exec rp_orader_closure_pxkg.rp_exaec_close_SILvl_WKO('aaa',
                                                     '1',
                                                     '10aaa001a6414339',
                                                     :output1, :output2);

回答by eaolson

I'm not sure all the SQLPlus commands work in SQL Developer. You can certainly do that in an anonymous block:

我不确定所有 SQLPlus 命令都在 SQL Developer 中工作。你当然可以在匿名块中做到这一点:

DECLARE
    output1 NUMBER;
    output2 VARCHAR2(100);
BEGIN
    rp_orader_closure_pxkg.rp_exaec_close_SILvl_WKO('aaa', '1', 
        '10aaa001a6414339', output1, output2);
END;

回答by DCookie

It works fine for me, SQL Developer v3.0.04. In the script window, I enter:

它对我来说很好用,SQL Developer v3.0.04。在脚本窗口中,我输入:

create or replace package p as
procedure prc (p1 in varchar2, p2 in out varchar2);
end;
/
create or replace package body p as
procedure prc (p1 in varchar2, p2 in out varchar2) is
begin
  p2 := p1;
end prc;
end;
/
variable output2 VARCHAR2(100);

exec p.prc('aaa',:output2);

print output2;

In the script output window:

在脚本输出窗口中:

PACKAGE p compiled
PACKAGE BODY p compiled
anonymous block completed
OUTPUT2
---
aaa

Perhaps I'm missing something?

也许我错过了什么?

回答by Daniel Hilgarth

Just lose the first two lines and execute only the line with execat the beginning. SQL developer will ask you for the values of the variables. Just leave them NULL, as they are output parameters.

只需丢失前两行并仅执行exec开头的行。SQL 开发人员会询问您变量的值。就留下它们吧NULL,因为它们是输出参数。