Home > database > Ask Daniel an oracle problem statement,
Ask Daniel an oracle problem statement,
Time:09-27
Is like that, I have A table. A, now there is A select collection of B, and C, (because the insert target table is 2, so can't use the merge into ps: or which Daniel has A good way,,,) I need to use the table data, A data collection with B according to field A, B do judgment (where A.a=B.a and a.=B.b), if the table has A the insert to the record table C, if there is no this record, insert into the table. A, how to write for Daniel insert all, just contact oracle 2 days, I hope you can teach me,
CodePudding user response:
Stored procedure write Idea is, defines a cursor to receive your collection Loop cursor, access to object and judge which is inserted into the table
CodePudding user response:
First insert A table: merge into A using B on (A.a=B.a and a.=B.b) when not matched insert A... Then insert table C: insert into C select * from A, B where A.a=B.a and a.=B.b