开发者

In Oracle PL/SQL is there any way to import packages and their members?

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)

DECLARE
  PRAGMA IMPORT dbms_output AS d;
  PRAGMA IMPORT foo AS f;
BEGIN
  d.put_line('f1 = ' || f.f1);
END;
/


Quite simply, you can't. Sorry, but there is no other answer!


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;
/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜