如何在Oracle软件包中执行私有过程? [英] How do I execute private procedures in an Oracle package?

查看:321
本文介绍了如何在Oracle软件包中执行私有过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试创建一个包,因此我必须丢失一些确实非常明显的东西(我搜索过的东西似乎都没有值得一提的东西.)

This is my first attempt at creating a package, so I must be missing something really really obvious (nothing that I've Googled for seems to even consider it worth mentioning).

很显然,如果您的程序包主体中有未包含在规范部分中的过程,则这些过程是私有的.我遇到的问题是,一旦制作完成,我似乎无法弄清楚如何引用.而且SQL Developer拒绝给我任何比警告完成执行"更有用的消息,这无济于事...

Obviously, if you have procedures in your package body that are not included in the specification section, then those procedures are private. The problem I've got is that I can't seem to figure out how to reference those private packages once I've made them. And SQL Developer refuses to give me any message more useful than 'execution completed with warning', which doesn't help...

作为一个例子,这就是我一直在尝试的不起作用(只会引发上述编译器错误):

As an example, this is what I've been trying that doesn't work (just throws the aforementioned compiler error):

CREATE OR REPLACE PACKAGE BODY testPackage AS

PROCEDURE privateProc; --Forward declaration

PROCEDURE publicProc IS
BEGIN
    EXECUTE privateProc();
END;

PROCEDURE privateProc IS
BEGIN
    DBMS_OUTPUT.PUT_LINE('test');
END;

END testPackage;

我还尝试将其称为testPackage.privateProc,但也没有用.

I've also tried referring to it as testPackage.privateProc, which hasn't worked either.

我在做什么错了?

推荐答案

我认为您应该这样做:

CREATE OR REPLACE PACKAGE BODY testPackage AS
PROCEDURE privateProc; --Forward declaration

PROCEDURE publicProc IS
  BEGIN    
    privateProc();
END;

PROCEDURE privateProc IS
BEGIN    
  DBMS_OUTPUT.PUT_LINE('test');
END;
END testPackage;

只需调用privateProc,就好像它是语言的一部分一样. Execute用于在PL/SQL内部运行DML或SQL.

Just call privateProc as if it is part of the language. Execute is for running DML or SQL inside your PL/SQL.

这篇关于如何在Oracle软件包中执行私有过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆