Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Location
    Paris
    Posts
    38

    Unanswered: definition of variable of which the type is externally defined

    Let's say that I have defined a type (table) in a package.

    I now want to write a script that uses this type in variable declaration.

    That is ok.

    The problem arises is on the initialisation of the varaible (ORA-06550). What am I doing wrong?


    Here is an example:


    Declare

    arrColumns pkg.type1 := pkg.type1('Col1');


    Begin

    ...

    End;
    Cordialement

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: definition of variable of which the type is externally defined

    Difficult to say without knowing your TYPE declaration and the actual error (ORA-06550 just says there was an error, there should be further error messages to explain what it actually was).

    In principle, it should work:

    Code:
    SQL> create or replace package p is
      2  type t is table of varchar2(10);
      3  end;
      4  /
    
    Package created.
    
    SQL> declare
      2    v p.t := p.t('one','two');
      3  begin
      4  null;
      5    for i in 1..v.count loop
      6      say('v('||i||')='||v(i));
      7    end loop;
      8* end;
    SQL> /
    v(1)=one
    v(2)=two
    
    PL/SQL procedure successfully completed
    .

  3. #3
    Join Date
    Feb 2003
    Location
    Paris
    Posts
    38
    The message translates to something like: "the function named <type name> does not exist in this scope".

    My type declaration is

    TYPE typColumnNames IS TABLE OF VARCHAR2(30) INDEX BY BINARY INTEGER;


    I get the same error message when trying to initialise in the BEGIN section.
    Cordialement

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You cannot initialise values in an INDEX BY table. You would either have to change your definition to:

    TYPE typColumnNames IS TABLE OF VARCHAR2(30);

    ... or set the values in the executable code:

    Code:
    DECLARE 
      x package.typColumnNames;
    BEGIN
      x(1) := 'Col1';
    ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •