i have a claims_tbl that i am inserting into with claim information, the tbl contains a claim_seq number that i want to copy over to a user_info_tbl at the same time insert user information below is what i have tried with no luck
insert into user_info(claim_seq)
select Max(claim_seq)
from claim_tbl
update user_info
set lname =upper(@.lname), fname =upper(@.fname), mname =upper(@.mname), personnel = @.personnel, p_position =upper(@.position)
where claim_seq = (Select Max(claim_seq) from user_info)
i am getting duplicate rows of information ........can someone help
thanks
I think you only need an INSERT statement. Perhaps your INSERT statement should look more like this?
INSERT INTOThis will only insert claim_seq values which do not already exists inthe user_info table, and will insert your parameter values at the sametime as the claim_seq.
user_info
(
claim_seq,
lname,
fname,
mname,
personnel,
p_position
)
SELECT
MAX(claim_seq),
upper(@.lname),
upper(@.fname),
upper(@.mname),
@.personnel,
upper(@.position)
FROM
claim_tbl
WHERE
NOT EXISTS (SELECT claim_seq FROM user_info WHERE claim_tbl.claim_seq = user_info.claim_seq)
|||
thanks for the help
the solution i use is below:
Select @.temp_seq = Max(incident_seq) from temp_id
insert into user_info(temp_seq, lname, fname, mname, personnel)
values(@.temp_seq, @.lname, @.fname,@.mname,@.personnel,)
No comments:
Post a Comment