Advertisements

Wednesday, March 6, 2013

How to query collections types in PL SQL

Tenemos definido los siguientes objetos type:


1CREATE OR REPLACE TYPE "SOAADM"."AP_INVOICES_IF_T" AS OBJECT (
2INVOICE_ID NUMBER,
3INVOICE_NUM VARCHAR2(50 BYTE),
4INVOICE_TYPE_LOOKUP_CODE VARCHAR2(25 BYTE),
5INVOICE_DATE DATE,
6VENDOR_ID NUMBER
7)
8 
9CREATE OR REPLACE TYPE "SOAADM"."AP_INVOICES_IF_TBL_T" AS TABLE OF AP_INVOICES_IF_T;


Ahora probamos con el siguiente script como saber si se pobló de manera correcta:
01declare
02  v_ap_if_tbl AP_INVOICES_IF_TBL_T;
03  v_ap_if_t AP_INVOICES_IF_T;
04  v_count number;
05begin
06  v_ap_if_t.INVOICE_ID:=1;
07  v_ap_if_tbl := AP_INVOICES_IF_TBL_T(v_ap_if_t);
08  select count(*) into v_count from table(cast(v_ap_if_tbl as AP_INVOICES_IF_TBL_T);
09  dbms_output.put_line('length: '||v_count);
10end;

No comments:

Post a Comment