Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    16

    Unanswered: multiple inserts error

    Hi,

    I am getting error becaue multiple fetch while select.
    Basically I want to insert into a temporary table in stored procedure

    My GTT structure is
    declare GTT temp_T1 ( ID_NUM INT , PACK_NUM INT , C3T1 CHAR,C4T1 INT).

    I want to insert into GTT data from another table as LP_PACK_DATA

    LP_PACK_DATA
    PACK_ID PACK_DATE, PACK_BY, SELF_CHECK
    23 01/03/02 KIO Y
    34 03/05/07 NMK N
    25 03/05/04 WEE Y
    14 03/01/07 CDE Y
    12 09/09/02 NMK -



    INSERT INTO TEMP_T1 (PACK_NUM) VALUES (SELECT PACK_ID FROM LP_PACK_DATA WHERE SELF_CHECK ='Y')

    I am getting error as
    SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES
    INTO statement is more than one row.

    Do I have to use cursor in this case or kindly suggest me if there is any multiple inserts can be done in above query.

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    NEE, Remove the Values( ) and just leave the Select.
    Code:
    INSERT INTO TEMP_T1
      (PACK_NUM)
      SELECT PACK_ID
      FROM LP_PACK_DATA
      WHERE SELF_CHECK = 'Y'

Posting Permissions

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