How to use a table type in a SELECT FROM statement?

后端 未结 5 701
花落未央
花落未央 2020-12-01 12:39

This question is more or less the same as this

In the package header :
Declared the following row type:

  TYPE exch_row IS RECORD(
             


        
5条回答
  •  天涯浪人
    2020-12-01 13:04

    In package specs you can do all you mentioned but not sure about INDEX BY BINARY_INTEGER;

    In package body:

    initialize the table in declarations:

    exch_rt exch_tbl := exch_tbl();
    

    in order to add record to the local collection, in begin - end block you can do:

    exch_rt.extend;
                                    one_row.exch_rt_usd := 2;
                                    one_row.exch_rt_eur := 1;
                                    one_row.currency_cd := 'dollar';
                                    exch_rt(1) := one_row; -- 1 - number of row in the table - you can put a variable which will be incremented inside a loop 
    

    in order to get data from this table , inside package body you can use:

    select exch_rt_usd, exch_rt_eur, currency_cd from table(exch_rt)
    

    enjoy!

    P.S. sorry for a late answer :D

提交回复
热议问题