使用 SQL Developer 创建包的问题
因此,我从未使用过存储过程,并且总体上没有太多的数据库经验,并且我被分配了一项需要我创建包的任务,但我陷入了困境。
使用 SQL Developer,我试图用这段代码创建一个名为 JUMPTO 的包...
create or replace package JUMPTO is
type t_locations is ref cursor;
procedure procGetLocations(locations out t_locations);
end JUMPTO;
当我运行它时,它会吐出这个 PL/SQL 代码块...
DECLARE
LOCATIONS APPLICATION.JUMPTO.t_locations;
BEGIN
JUMPTO.PROCGET_LOCATIONS(
LOCATIONS => LOCATIONS
);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('LOCATIONS = ' || LOCATIONS);
END;
我发现一个教程说要删除那一秒的注释在那里排队。 我尝试过带评论和不带评论。
当我点击“确定”时,我收到错误...
ORA-06550: line 2, column 32:
PLS-00302: component 'JUMPTO' must be declared
ORA-06550: line 2, column 13:
PL/SQL: item ignored
ORA-06550: line 6, column 18:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
ORA-06512: at line 58
我真的不知道发生了什么,这对我来说是全新的领域。 我尝试创建一个刚刚从数据库中选择一些内容的主体,但没有任何东西像我想象的那样工作。 谁能给我对此的任何见解?
So I've never worked with stored procedures and have not a whole lot of DB experience in general and I've been assigned a task that requires I create a package and I'm stuck.
Using SQL Developer, I'm trying to create a package called JUMPTO with this code...
create or replace package JUMPTO is
type t_locations is ref cursor;
procedure procGetLocations(locations out t_locations);
end JUMPTO;
When I run it, it spits out this PL/SQL code block...
DECLARE
LOCATIONS APPLICATION.JUMPTO.t_locations;
BEGIN
JUMPTO.PROCGET_LOCATIONS(
LOCATIONS => LOCATIONS
);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('LOCATIONS = ' || LOCATIONS);
END;
A tutorial I found said to take out the comment for that second line there. I've tried with and without the comment.
When I hit "ok" I get the error...
ORA-06550: line 2, column 32:
PLS-00302: component 'JUMPTO' must be declared
ORA-06550: line 2, column 13:
PL/SQL: item ignored
ORA-06550: line 6, column 18:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
ORA-06512: at line 58
I really don't have any idea what's going on, this is all completely new territory for me. I tried creating a body that just selected some stuff from the database but nothing is working the way it seems like it should in my head. Can anyone give me any insight into this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要声明一个包体,例如:
要编译需要这样:
First of all you need to declare a package body, for instance:
To compile need this:
Oracle PL/SQL 包有 2 个部分:
您的第一段代码声明了包规范 (JUMPTO)。 您声明了一种类型 (t_locations) 和一个没有输入的过程 (procGetLocations),但输出一个 t_locations 类型的变量 (locations)。
首先编译包规范(就像您所做的那样),然后像这样编译包主体:
现在您可以在其他 PL/SQL 块(匿名或其他方式)中调用过程 procGetLocations。
An Oracle PL/SQL package has 2 parts:
Your first piece of code declared the package specification (JUMPTO). You declared a type (t_locations) and a procedure (procGetLocations) that has no inputs, but outputs one variable (locations) of type t_locations.
First compile the package spec (as you did), then compile the package body like so:
Now you can call the procedure procGetLocations in other PL/SQL blocks (anonymous or otherwise).