开发者

using record types - declaration and body in package

开发者 https://www.devze.com 2023-04-10 18:53 出处:网络
I have problem with my package its looks like: create or replace PACKAGE pac AS TYPE A IS RECORD ( aa VARCHAR2(255)

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.registerOu开发者_如何学编程tParameter(1, Types.ARRAY,...);
call.execute();
array = call.getArray(1);


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.

0

精彩评论

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