CREATE OR REPLACE PROCEDURE Zxt_type_Study Is
/*
type 的使用
*/
Testrow1 Test%ROWTYPE;
TYPE Aa IS TABLE OF Test%Rowtype;
Testrow Aa := Aa();
TYPE Bb IS TABLE OF Test.ac%Type;
Cc Bb;
Testrow2 Test%ROWTYPE;
t Test.Ac%TYPE;
BEGIN
Testrow2.Ac := 'a3';
Testrow2.Breanch := 'zxtss';
Testrow2.Amt := 5000;
--取update的结果
UPDATE Test SET ROW = Testrow2 WHERE Ac = Testrow2.Ac RETURNING Ac, Breanch, Amt INTO Testrow1;
--给type付值
FOR i IN (SELECT * FROM Test) LOOP
Testrow.EXTEND;
Testrow(Testrow.LAST) := i;
Testrow2 :=i;
Dbms_Output.Put_Line('ac1=' || Testrow2.Ac || ';breanch1=' || Testrow2.Breanch || ';amt1=' || Testrow2.Amt);
END LOOP;
Dbms_Output.Put_Line('ac=' || Testrow1.Ac || ';breanch=' || Testrow1.Breanch || ';amt=' || Testrow1.Amt);
--给type付值1
SELECT Test.Ac BULK COLLECT INTO Cc FROM Test;
--forall的使用
FORALL j IN Cc.FIRST .. Cc.LAST
UPDATE Test SET Test.Amt = 1000 WHERE Test.Ac = Cc(j);
--取type中的一个值
FOR y IN Cc.FIRST .. Cc.LAST LOOP
Dbms_Output.Put_Line('cc(y)' || Cc(y));
END LOOP;
Dbms_Output.Put_Line('t=' || t);
--打印执行前边的sql结果集的条数
Dbms_Output.Put_Line('sql=' || SQL%ROWCOUNT);
END Zxt_type_Study;