Inserting parent and child tables at a time

5 pts.
Tags:
Oracle Database
Oracle Statements
TOAD
Is there any way to insert parent and child tables data with select statement? On record in parent table and n number of records in child table. Please let me know if possible.

Software/Hardware used:
toad

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    More details are needed. Are you usging an Oracle database ? If so, what version ? Why do you need to insert into a master and a detail table at the same time ? Is the data that you need to insert into the parent table comming from the same SELECT statement that the data that you are going to insert into the child table ? The more details you provide, the better chances to get a useful response.
    68,525 pointsBadges:
    report
  • Meandyou
    Carlosdl, I guess he doesn't have any more details.
    5,220 pointsBadges:
    report
  • Par60056
    I know this thread died a couple years ago but I am searching for an answer to this for the first time. So let me give an example: I have a system that has several 100K records. I am summarizing that data in a query to feed into the source tables for another system. The normal operation would be to insert all the Parent table records and then insert the children using a subquery to find the appropriate parent key. However, the only field in the parent table that is required to be unique is the report identifier. It is possible to have people make multiple reports with all the same information in the parent record but they make changes to the options in the children and the reports have to be kept separate. These tables are generally populated by the user making selections in an interface so this is not an issue. Now they want to define a set of reports automatically by feeding in the data from another system. So I have something like this coming from the query: A xx 1 A yy 2 A zz 2 A WW 4 B XX 4 B WW 2 C xx 3 C yy 5 C tt 3 And I want to end up with tables like: I want to get: Parent: 1 A 2 B 3 C Child: 1 xx 1 1 yy 2 1 zz 2 1 ww 4 2 XX 4 2 WW 2 3 xx 3 3 yy 5 3 tt 3 Obviously, there are about 10 fields from the query that go into the parent and 8 fields that go into the child but I wanted to keep the example simple.
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following