Compare data and insert unique data (merged) [message #411979] |
Tue, 07 July 2009 06:36  |
gozuhair
Messages: 206 Registered: January 2008
|
Senior Member |
|
|
Dear All
Please guide me,I have created the following code.
1-User input code through form 6i
2-on when button press trigger,system will get ro_make_cd,ro_fren_cd
from ro_fren_dtl table.(there is no colums of code in this table)
3-insert the user input code,ro_make_cd and ro_fren_cd into non_lts_dtl table.
By doing this there are lots of duplicates rows inserted in non_lts_dtl table ,Now I want to control duplication.
The system can ideally work by using the following scenario.
-User input the code like 'FFS'(by using form 6i)
-system extract ro_make_cd,ro_fren_cd from ro_fren_dtl(master table of column stated) by using cursor.
-system also extract all code,ro_make_cd and ro_fren_cd from non_lts_dtl table by using cursor.
-compare both data like
user input code(comes from form 6i),ro_fren_cd,ro_make_cd compare with code,ro_make_cd and ro_fren_cd(comes from non_lts_dtl)
and incase of duplication with the combination of code,ro_fren_cd,ro_make_cd discard it otherwise insert it into non_lts_dtl table.
Please advise how can i get my desired result.
My table structers are:
desc ro_fren_dtl
RO_FREN_CD VARCHAR2(5)
RO_MAKE_CD VARCHAR2(5)
desc non_lts_dtl
RO_FREN_CD VARCHAR2(5)
RO_MAKE_CD VARCHAR2(5)
CODE VARCHAR2(6)
I am using the following code(this code insert data but not control duplication) to insert data in non_lts_dtl
DECLARE
CURSOR c1 IS
SELECT a.ro_fren_cd,
a.ro_make_cd,
:code
FROM ro_fren_dtl a
WHERE ro_fren_cd IN ('01','02','03','04');
col_rec c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO col_rec;
EXIT WHEN c1%NOTFOUND;
INSERT INTO non_lts_dtl
(ro_fren_cd,
ro_make_cd,
code)
VALUES (col_rec.ro_fren_cd,
col_rec.ro_make_cd,
:code);
END LOOP;
CLOSE c1;
END;
commit;
|
|
|
|
|
|
|
|
Re: Compare data and insert unique data (merged) [message #412339 is a reply to message #412232] |
Wed, 08 July 2009 14:37  |
cookiemonster
Messages: 13964 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
gozuhair wrote on Wed, 08 July 2009 11:43 | The problem is that i am using form 6i for input code but i am unable to compare it with non_lts_dtl table.how can i compare it with non_lts_dtl table,please guide
|
By using NOT EXISTS in the cursor.
Try it.
The fact that you're using forms is irrelevant.
|
|
|