OraQA

Oracle Question and Answer


Latest Comments

  • Laurent Schneider:
    if you like a Base64 format, maybe this… select utl_raw.cast_to_varchar 2(...

  • hsafra:
    You need to give more specs for the question: What letter are acceptable? What letters aren’t? Do you...

  • ragunathansd:
    I am not inserting sequence numbers from database. I need to populate the data in a grid. If a user...

  • gamyers:
    “redo log file gets full” That is the nature of a redo log file. It gets full, switched and...

Comments RSS feed


  • Do you have a solution to a problem? Do you have an unanswered question? Login and share it with the Oracle community. More...

Oracle News


Entries RSS feed

Comments RSS feed

How to convert type to table?

October 11th, 2006 By plasma

CREATE OR REPLACE TYPE mytype AS OBJECT (
   field_1   VARCHAR2 (256),
   field_2   VARCHAR2 (256),
   field_3   VARCHAR2 (256),
   field_4   VARCHAR2 (256),
   field_5   VARCHAR2 (256)
)
FINAL;
/

CREATE OR REPLACE TYPE myarray IS TABLE OF mytype;
/

DECLARE
   la_myarray          myarray        := myarray ();
   lvc_search_string   VARCHAR2 (512);
BEGIN
   FOR ln_i IN 1 .. 10
   LOOP
      la_myarray.EXTEND;
      la_myarray (la_myarray.LAST) :=
         mytype ('a' || ln_i,
                 'b' || ln_i,
                 'c' || ln_i,
                 'd' || ln_i,
                 'e' || ln_i
                );
   END LOOP;

   SELECT   a.field_2
       INTO lvc_search_string
       FROM la_myarray a
      WHERE a.field_3 LIKE '%7'
   ORDER BY a.field_5;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);
END;

How can I select from my array? is this possible?

One Response to “How to convert type to table?”

  1. gamyers Says:

    Simply use “FROM TABLE(la_myarray) a”
    This works in 9iR2.

Leave a Reply

You must be logged in to post a comment.

RSS feed for comments on this question