Home » Developer & Programmer » Forms » Multiple row problem (Developer 6i, Oracle 9i, Winxp)
Multiple row problem [message #396217] Sun, 05 April 2009 02:22 Go to next message
mahatab
Messages: 98
Registered: January 2008
Location: Dhaka
Member

Hi,
I have got multiple rows returns according to my conditions. now i have to insert those record into another table using the for loop, each record at a time and to do so i have written the following code to solve my problem but its not working and showing me the error of ORA-01422: What to do? Can anyone please help me out? here is the code:
begin
	IF :PRODUCT_INFO.CHECK ='Y' THEN	
		first_record;
loop	
	
		 SELECT ALL  DEALER_CONTRIBUTION.DISTRIBUTOR_CODE,       
 DISTRIBUTOR_INFO_2.DISTRIBUTOR_NAME,          
 PRODUCT_TARGET1.YEAR_NO,            
 PRODUCT_TARGET1.MONTH_ID,               
 DEALER_CONTRIBUTION.PRODUCT_CODE,
 DEALER_CONTRIBUTION.PRODUCT_NAME,          
 ((DEALER_CONTRIBUTION.CONTRIBUTION/100)*( PRODUCT_TARGET1.TARGET_QTY))TARGETED_QTY_MONTHLY,   
 (((DEALER_CONTRIBUTION.CONTRIBUTION/100)*( PRODUCT_TARGET1.TARGET_QTY))*(DEALER_CONTRIBUTION.INV_RATE))TARGETED_AMT_MONTHLY,                                  
 DEALER_CONTRIBUTION.INV_RATE  
 

INTO DISTRIBUTOR_CODE,       
DISTRIBUTOR_NAME,           
TARGET_YEAR,            
MONTH_ID,               
PRODUCT_CODE,
PRODUCT_NAME,          
TARGETED_QTY_MONTHLY,   
TARGETED_AMT_MONTHLY,                                  
INV_RATE
FROM DEALER_CONTRIBUTION,PRODUCT_TARGET1,DISTRIBUTOR_INFO_2
WHERE DEALER_CONTRIBUTION.PRODUCT_CODE=PRODUCT_TARGET1.PRODUCT_CODE AND DEALER_CONTRIBUTION.YEAR_NO=PRODUCT_TARGET1.YEAR_NO AND 
DISTRIBUTOR_INFO_2.DISTRIBUTOR_CODE=DEALER_CONTRIBUTION.DISTRIBUTOR_CODE; 
INSERT INTO DEALER_TARGET_TBL2(DISTRIBUTOR_CODE,       
DISTRIBUTOR_NAME,       
TARGET_YEAR,            
MONTH_ID,               
PRODUCT_CODE,
PRODUCT_NAME,          
TARGETED_QTY_MONTHLY,   
TARGETED_AMT_MONTHLY,                                  
INV_RATE)
VALUES(DISTRIBUTOR_CODE,       
DISTRIBUTOR_NAME,           
TARGET_YEAR,            
MONTH_ID,               
PRODUCT_CODE,
PRODUCT_NAME,          
TARGETED_QTY_MONTHLY,   
TARGETED_AMT_MONTHLY,                                  
INV_RATE);
--GO_BLOCK('DEALER_TARGET_TBL2');
	--execute_query();
	COMMIT;
	exit when :system.last_record = 'TRUE';	
	next_record;
  end loop;
end if;
  commit;
END;
Re: Multiple row problem [message #396221 is a reply to message #396217] Sun, 05 April 2009 03:35 Go to previous message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is useless to start a new topic to repeat the same question.
BUT you should follow what we ask instead:
Michel Cadot wrote on Sun, 05 April 2009 07:11
If you really write your code like this I understand you can't see if there is an error.
Format your code, indent it, use a code formatter (for instance http://www.orafaq.com/utilities/sqlformatter.htm).

Regards
Michel

And keep your lines in 80 characters width.

[Updated on: Sun, 05 April 2009 03:36]

Report message to a moderator

Previous Topic: how to get IP ADDRESS of server machine
Next Topic: Need some help/Tips
Goto Forum:
  


Current Time: Fri Dec 02 18:54:37 CST 2016

Total time taken to generate the page: 0.25403 seconds