SQL> create type item_rec is object(item varchar2(20),desc_ varchar2(30));
2 /
Type created
SQL> create type item_list is type of item_rec;
2 /
Warning: Type created with compilation errors
SQL> create type item_list is table of item_rec;
2 /
Type created
SQL>
second In a procedure
CREATE OR REPLACE PROCEDURE tst_bom
(t_Result OUT ITEM_LIST)
IS
i NUMBER;
TYPE rec_Item IS RECORD(Item VARCHAR2(20),
desc_ VARCHAR2(30));
TYPE rec_Tab IS TABLE OF REC_ITEM;
Item_Tab REC_TAB;
BEGIN
FOR i IN 1.. 10 LOOP
Item_Tab(i).Item := 'item'
||To_Char(i);
Item_Tab(i).desc_ := 'description'
||To_Char(i);
END LOOP;
END tst_bom;
DECLARE
2 i NUMBER;
3 Item_Tab ITEM_LIST := item_list();
4 t_Result ITEM_LIST;
5 BEGIN
6 FOR i IN 1.. 10 LOOP
7 item_tab.extend;
8 item_tab(i) := item_rec('item'||To_Char(i),'description'||To_Char(i));
9 END LOOP;
10
11 select item_rec(item,desc_) bulk collect into t_result from table(item_tab);
12 for i in 1..item_tab.count loop
13 dbms_output.put_line(t_result(i).item||' '||t_result(i).desc_);
14 end loop;
15 END;
16 /
Halim, a Georgia Tech graduate Senior Database Engineer/Data Architect based in Atlanta, USA, is an Oracle OCP DBA and Developer, Certified Cloud Architect Professional, and OCI Autonomous Database Specialist. With extensive expertise in database design, configuration, tuning, capacity planning, RAC, DG, scripting, Python, APEX, and PL/SQL, he combines technical mastery with a passion for innovation. Notably, Halim secured 16th place worldwide in PL/SQL Challenge Cup Playoff on the year 2010.
Friday, September 11, 2009
Subscribe to:
Post Comments (Atom)
My Blog List
-
-
-
ASSM states3 weeks ago
-
UKOUG Discover 20241 month ago
-
-
-
-
-
-
-
-
Moving Sideways8 years ago
-
-
Upcoming Events...11 years ago
-
No comments:
Post a Comment