Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2016
    Posts
    1

    Unanswered: Multiple Rows read in Stored Procedure

    Hi All,

    I am using SP, where the output of the Select query can be multiple rows. I need to process some requirement based every time, like a loop. I read somewhere that CONTINUE HANDLER is used for this but not able to put it in right place.Here is the sample:

    SET al_str_err_decsription = ' SELECT ' || al_str_key_column_nm || ' ,
    CDC_VALID_FROM,
    CDC_USERID,
    CDC_STATUS,
    CDC_AUDITTYPE
    FROM MAX_HIST.' || s$srctabid ||
    ' WHERE CDC_ISVALID = 2
    ORDER BY CDC_VALID_FROM ' ;

    PREPARE al_dynamic_cursor_sql FROM al_str_err_decsription;

    OPEN carrier_cur;

    FETCH carrier_cur INTO al_int_key_col_val, al_dtm_valid_from,al_str_chg_person_id, al_str_record_status,al_str_aud_type;

    CLOSE carrier_cur;

    Update Statements--------------------------------------------------------------------------

    Here the output of select columns can be multiple rows (say 5) so I need to run these update statements 5 times for 5 different values of columns.

    Thanks in advance !!!!

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    559
    Provided Answers: 2
    Use a WHILE or a FOR loop
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Tags for this Thread

Posting Permissions

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