在 Oracle PL/SQL 中有没有办法导入包及其成员?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5650319/
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:19:56 来源:igfitidea点击:
In Oracle PL/SQL is there any way to import packages and their members?
提问by user272735
Given a package:
给定一个包:
create or replace package foo as
f1 number := 1;
end;
/
Instead of:
代替:
declare
begin
dbms_output.put_line('f1 = ' || foo.f1);
end;
/
I'd like to write:
我想写:
declare
begin
-- pseudocode not a valid PL/SQL
import dbms_output.*;
import foo.*;
put_line('f1 = ' || f1);
end;
/
But how to do that ?
但是怎么做呢?
EDIT by Jeff:(trying to stay in the spirit of how things are done in PL/SQL)
Jeff 编辑:(试图保持在 PL/SQL 中完成事情的精神)
DECLARE
PRAGMA IMPORT dbms_output AS d;
PRAGMA IMPORT foo AS f;
BEGIN
d.put_line('f1 = ' || f.f1);
END;
/
回答by Tony Andrews
Quite simply, you can't. Sorry, but there is no other answer!
很简单,你不能。抱歉,没有其他答案!
回答by Jeffrey Kemp
Of course you can!
当然可以!
:) sort of...
:) 有点...
declare
procedure put_line (p in varchar2) is begin dbms_output.put_line(p); end;
function f1 return number is begin return foo.f1; end;
begin
put_line('f1 = ' || f1);
end;
/