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!

MultiLine Insert

642183May 30 2008 — edited May 30 2008
Hello everybody,
i've got a little problem creating an SQL-statement, inserting multiple rows. I've got 3 tables which could be simplyfied like this:

Table1
ID | UserID | JobID
-------------------------
1 | 1 | 1
2 | 1 | 2
3 | 2 | 1

Table2
ID | User
------------
1 | Jon
2 | Mike
3 | George

Table3
ID | Job
----------
1 | Buy
2 | Sell

In fact, the real tables 2 and 3 hold much more informations. Well now I want to do something like this:

insert into Table1(ID, UserID, JobID) values(
Table1Sequence.nextVal,
(select ID from Table2 where User='George'),
(select JobID from Table1 where UserID=
(select ID from Table2 where User='Jon')));

To describe what i want to do is:
1. Search the id of a user
2. Get all JobID's this user has
3. Search the id of an other user
4. Give the same JobID's of the first user to the second user.

The SQL-Statement i created works fine if the first user only has one job, but it may have more....

Could anybody help me?
Thx
Beat
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2008
Added on May 30 2008
4 comments
1,032 views