I'm having issues to perform one mass update in our Oracle DB.
I would like to do mass insert to mapping table which we can call map
There are other two tables from which I have to obtain the data The first table is the account table from which I can select the desired accounts for inserting with this query:
select account_id
from account
where company_id in (
select company_id
from company
where company_name = 'string');
This query will select my all the accounts depending on the company name which I want to insert.
Next I have table which we can call group and in this table I have exact number of groups which I inserted, groups have UIDs so we have group_id 1 to 500.
Here is what i need to do: I need to insert into table map UID mappings between the accounts and groups. There is no special order in which needs to be done
insert into map (account_id, group_id)
values (number,number);
But unfortunately I don't know how to do such mass insert with selects which are containing more then one result and also how to count the looping.
So my idea is do something like this:
insert into map (account_id, group_id) values ((select account_id
from account
where company_id in (
select company_id
from company
where company_name = 'string')),loop from 1 to 500);
With rule that group_id can be inserted with many account_ids but one account_id can be linked only to one group.
Of course this query will not work, I'm just trying to express what I want to do. Hope this make sense.
I since I know what exactly I want to insert where and I have all the counts I know that I have 500 account_ids and 50 group_ids. Also they are in order meaning account_id 1 to 500 and group_id 1 to 500, so I think in this case it should be fairly easy to loop the insert somehow.
I hope I have made myself clear as much as possible.
Thank you for your answers and suggestions!