Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Location
    India
    Posts
    40

    Unanswered: PL/SQL is not getting total data into a file..please help me

    I have the following code, which is running correctly...

    All the declaration was correct....but at the time of fetching the records..it is not
    fetching all the records.. what is wrong in my code...should i change any thing in
    for loop or what...else please help me to correct the error.

    ************************************************** ******
    CURSOR one is
    SELECT
    A,
    B,
    C,
    D
    From Q
    Where
    ---;

    CURSOR two is
    SELECT
    A,
    B,
    C,
    D
    From Q
    Where
    ---
    ---
    ---
    ---;


    CURSOR three is
    SELECT
    A,
    B,
    C,
    D
    From Q
    Where
    ---
    ---;


    CURSOR four is
    SELECT
    A,
    B,
    C,
    D
    From Q
    Where
    ---
    ---
    ---;

    BEGIN

    utl_file.fclose_all;

    Var_File := 'datatest.csv';

    Var_FileHandle := utl_file.fopen('D:\data\',Var_File,'W');

    FOR WS1_Rec in one LOOP

    Var_WSalRecord1 := WS1_Rec.one;

    FOR WS2_Rec in two LOOP

    Var_WSalRecord2 := WS2_Rec.two;

    FOR WS3_Rec in three LOOP

    Var_WSalRecord3 := WS3_Rec.three;

    FOR WS4_Rec in four LOOP

    Var_WSalRecord4 := WS3_Rec.four;

    end LOOP;
    end LOOP;
    end LOOP;

    utl_file.put_line(Var_FileHandle, Var_WSalRecord1||Var_WSalRecord2||Var_WSalRecord3| |Var_WSalRecord4);


    utl_file.fflush(Var_FileHandle);

    end LOOP;

    utl_file.fclose(Var_FileHandle);


    *********************************************
    Suryadevara

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    If I understood well, you'd like to write ALL combinations into the output file?

    Your code does fetch all the records, but you don't write them all. I'd suggest to put utl_file.put_line command into the FOURTH loop (behind Var_WSalRecord4 := ...), as the loops are nested.

Posting Permissions

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