Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    Oklahoma City OK -
    Posts
    122

    Unanswered: loop thru an array by date order ,not loaded sequentially by date

    If I load an array, How do I then loop thru the array by date order assuming It has not been loaded sequentially by date?
    Code:
    TYPE T_SEQ            IS TABLE OF NUMBER (2)                  INDEX BY BINARY_INTEGER; 
    TYPE T_OUTPUT_LINE        IS TABLE OF VARCHAR2 (200)              INDEX BY BINARY_INTEGER;
    TYPE T_DATE                  IS TABLE OF DATE	  					 INDEX BY BINARY_INTEGER;
    
    ROW_SEQ                      T_SEQ;
    ROW_OUTPUT_LINE              T_OUTPUT_LINE;
    ROW_DATE                     T_DATE;
    I'm sure this is quite simple, just can't see the answer.

    Thanks,

  2. #2
    Join Date
    Oct 2004
    Location
    Oklahoma City OK -
    Posts
    122
    Solution

    Convert the derived date to a number and assign the value to your index
    I := TO_NUMBER(REPLACE(TO_CHAR(TO_DATE(v_celebrated,'MM/DD/YYYY'),'YYYY/MM/DD'),'/', NULL) );

    Then use
    i := ROW_DATE.FIRST;


    WHILE i IS NOT NULL LOOP
    dbms_output.put_line(ROW_TEXT(I)|| ' '||ROW_CELEBRATED(I)||' '||ROW_DAY(I) );
    i := ROW_DATE.NEXT(i);
    END LOOP;

    to loop thru the table to print in desired order.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •