Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create an insert into a table with a common identifiers from two other tables for a single re

Rhine23May 31 2017 — edited Jun 14 2017

Hi Team.

I hope you could please assist me with this one. I have 4 table as per below.

Users Table

column name
type
User_id (pk)Number (generated by SQ)
Email_address (u)Varchar2
PasswordVarchar2
Created_byVarchar2

users_pk01(user_id)

users_un01(email_address)

Billing_Accounts table

column name
type
Billing_account_id (pk)Number (generated by SQ)
Business_nameVarchar2
created_byvarchar2

billing_accounts_pk01(billing_account_id)

Organizations table

Column name
type
Organization_id(pk)number (generated by SQ)
billing_account_id (fk) (organization_fk01 (billing_account_id))number
Created_byVarchar2

organization_users_pk01 (organization_user_id)

organization_users_un01 (organization_id, user_id)

organization_users_fk01 (organization_id)

organization_users_fk02 (user_id)

Organizations_users table

Column
type
Organization_user_id(pk)number (generated by SQ)
Organization_id(uf)number
user_id(uf) number
created_byvarchar2

organization_users_pk01 (organization_user_id)

organization_users_un01 (organization_id, user_id)

organization_users_fk01 (organization_id)

organization_users_fk02 (user_id)

So what happens is that when a user registers their details an insert occurs into the Users Table then the user has to create a billing account so when the insert into billing account happens i want the user_id (already in the users table) to be inserted into the Organizations_users table and the billing_account_id for this same user from the Billing_Accounts table to be inserted into Organizations table. for the same user

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2017
Added on May 31 2017
6 comments
950 views