Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute Immediate (Merge Statement) in a Loop

Status
Not open for further replies.

rdharmar

IS-IT--Management
Jun 20, 2001
54
US
I have dyanamically built a Merge statement and I am trying to do an Execute Immediate on it. I am able to run the Merge statement individually without issues.

When the same is done through the Execute Immediate it fails: ORA-00001: unique constraint (GPS.DETAILS37150433_PK) violated.

MERGE INTO DETAIL37150433 dp USING ( SELECT 208670 as id FROM dual) dp1 ON ( dp.ID = dp1.id ) WHEN MATCHED THEN UPDATE SET PhaseNumber='2' WHEN NOT MATCHED THEN INSERT (ID,PROGRESSTYPE,CONTRACT, PhaseNumber) VALUES (208670,185890,37150433,'EA');

Any pointer would help.

Thanks
Ram
 
Thanks. I had not defined a PK for the table. so this works now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top