Procedure - Dates Between

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • datanut
    New Member
    • Sep 2008
    • 1

    Procedure - Dates Between

    I need to make a table (tabel B) using table A. THANKS!

    My current table
    MBR_SID MinD MaxD
    A 1/1/2008 1/10/2008

    I need a table like this

    mbr day
    A 1/1/2008
    A 1/2/2008
    A 1/3/2008


    I have a start --

    CREATE OR REPLACE PROCEDURE PNMI_DAY AS

    -- Declare Local Variable

    StartDate DATE;
    EndDate DATE;
    CurrentDate DATE;

    AdDate DATE; ---this is the bumping date...



    BEGIN

    StartDate := '01-JAN-2007'; -- Format (MM/DD/YYYY)
    EndDate := '31-DEC-2007';
    CurrentDate := StartDate;

    EXECUTE IMMEDIATE 'TRUNCATE TABLE PNMI_DAYS';

    WHILE CurrentDate <= EndDate

    LOOP

    INSERT INTO PNMI_DAYS (MBR_SID, DAYS)
    SELECT DISTINCT MBR_SID,
    TO_CHAR(MIND,'M M/DD/YYYY')
    FROM PNMI_MBR
    WHERE MBR_SID = 31500
    AND MIND <= CurrentDate
    AND MAXD >= CurrentDate;


    CurrentDate := CurrentDate+ 1;


    END LOOP;
    END Pnmi_Day ;

    /
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Why not use the create table as select ... statement instead?

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      just do as suggested in the previous reply. there is no use writing a procedure just to create a table.

      Comment

      Working...