If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > multiple inserts error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-28-09, 17:47
NEE NEE is offline
Registered User
 
Join Date: May 2009
Posts: 16
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.
Reply With Quote
  #2 (permalink)  
Old 05-28-09, 18:42
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
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'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On