使用记录类型 - 包中的声明和主体

发布于 12-08 12:40 字数 391 浏览 0 评论 0 原文

我的包有问题,它看起来像:

create or replace
PACKAGE pac AS
  TYPE A IS RECORD
(
  aa VARCHAR2(255)
);

 TYPE B is ARRAY(1) of A;

 PROCEDURE proc1( som OUT B);

然后当我创建主体时它失败,这个记录类型有问题..

我这样做是因为然后在java中我做了

call = connection.prepareCall(...);
call.registerOutParameter(1, Types.ARRAY,...);
call.execute();
array = call.getArray(1);

I have problem with my package its looks like:

create or replace
PACKAGE pac AS
  TYPE A IS RECORD
(
  aa VARCHAR2(255)
);

 TYPE B is ARRAY(1) of A;

 PROCEDURE proc1( som OUT B);

then when I'm creating body its fails, there is problem with this record type..

I'm doing this that way because then in java I made

call = connection.prepareCall(...);
call.registerOutParameter(1, Types.ARRAY,...);
call.execute();
array = call.getArray(1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落花随流水 2024-12-15 12:40:58

您的示例包代码不是语法上有效的 PL/SQL 代码,并且您没有提供错误详细信息。这是我的猜测你想要做什么:

/* First part of a package is a specification that declares public items 
   that can be called outside of the package. */
create or replace package pac as

  type a is record (
    aa varchar2(255)
  );

 type b is array(1) of a;

 procedure proc1(som out B);

end;
/

/* Second part is a body that defines cursors and subprograms (in this case 
   proc1-procedure). */
create or replace package body pac as

  procedure proc1(som out b) as
    v_a a;
  begin
    v_a.aa := 'foo';
    som := b(v_a);
  end;

end;
/

declare
  v_som pac.b;
begin
  pac.proc1(v_som);
  dbms_output.put_line(v_som(1).aa); /* prints foo */
end;
/

另请参阅 Oracle 的有关 "="">PL/SQL 包。

Your example package code is not a syntactically valid PL/SQL code and you don't provide the error details. Here is my guess what you're trying to do:

/* First part of a package is a specification that declares public items 
   that can be called outside of the package. */
create or replace package pac as

  type a is record (
    aa varchar2(255)
  );

 type b is array(1) of a;

 procedure proc1(som out B);

end;
/

/* Second part is a body that defines cursors and subprograms (in this case 
   proc1-procedure). */
create or replace package body pac as

  procedure proc1(som out b) as
    v_a a;
  begin
    v_a.aa := 'foo';
    som := b(v_a);
  end;

end;
/

declare
  v_som pac.b;
begin
  pac.proc1(v_som);
  dbms_output.put_line(v_som(1).aa); /* prints foo */
end;
/

Please see also Oracle's documentation about PL/SQL packages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文