Oracle 11gR2 SQL Reference Tips

使用Collection

http://docs.oracle.com/cd/B10501_01/appdev.920/a96624/05_colls.htm

Example:

DECLARE
  TYPE [USER_DEFINED_TYPE_NAME] IS TABLE OF [TABLE].[COLUMN]%TYPE;
  [VARIABLE_NAME] [USER_DEFINED_TYPE_NAME];

BEGIN
  SELECT [COLUMN] BULK COLLECT INTO [VARIABLE_NAME] FROM [TABLE] WHERE [CONDITIONS];
  FOR i IN 1..[VAIRABLE_NAME].COUNT LOOP
    BEGIN
      DBMS_OUTPUT.PUT_LINE(' DATA: '||[VARIABLE_NAME](i));
      ...
    END;
  END LOOP;
END;

Continue reading Oracle 11gR2 SQL Reference Tips

Advertisements