Home » SQL & PL/SQL » SQL & PL/SQL » MULTIPLE DYNAMIC INSERTION (SQL DEVELOPER)
MULTIPLE DYNAMIC INSERTION [message #395785] Thu, 02 April 2009 10:18 Go to next message
Krishna_dev
Messages: 32
Registered: May 2007
Member
I have a set of records I would create in a table. I am first inserting the first row of records as follows.
COMPANY,LOCATION,SERVICE,FUTURE

Once I have inserted the first row of records I would like to insert another 3 records derived from the first one but only the value of SERVICE will change. So the end result will be

COMPANY,LOCATION,SERVICE,FUTURE
COMPANY,LOCATION,SERVICE1,FUTURE
COMPANY,LOCATION,SERVICE2,FUTURE
COMPANY,LOCATION,SERVICE3,FUTURE

What is the most efficient way to do this in PL/SQL?

Re: MULTIPLE DYNAMIC INSERTION [message #395791 is a reply to message #395785] Thu, 02 April 2009 10:29 Go to previous messageGo to next message
BlackSwan
Messages: 25035
Registered: January 2009
Location: SoCal
Senior Member
>I would like to insert another 3 records derived from the first one but only the value of SERVICE will change.
Why 4 records & not only 1?

COMPANY,LOCATION,SERVICE, SERVICE1, SERVICE2, SERVICE3,FUTURE

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/

[Updated on: Thu, 02 April 2009 10:30]

Report message to a moderator

Re: MULTIPLE DYNAMIC INSERTION [message #395793 is a reply to message #395785] Thu, 02 April 2009 10:32 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Krishna. The people here at OraFaq are generally pretty clever folks. You don't have to overly simplify your question for us. If you tell us what you actually need, someone will most likely be able to give you a good answer. If you ioversimplify, you are likely to end up getting more questions fired back at you for clarification.

[Edit:] Q.E.D.

[Updated on: Thu, 02 April 2009 10:33]

Report message to a moderator

Re: MULTIPLE DYNAMIC INSERTION [message #395824 is a reply to message #395793] Thu, 02 April 2009 13:21 Go to previous messageGo to next message
Krishna_dev
Messages: 32
Registered: May 2007
Member
dear pablolee. If the question had in fact been oversimplified, then would'nt you, in all your infinite wisdom, have simply answered it.
Re: MULTIPLE DYNAMIC INSERTION [message #395828 is a reply to message #395824] Thu, 02 April 2009 13:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
The most efficient way is to do it in SQL and INSERT ALL.

Regards
Michel
Re: MULTIPLE DYNAMIC INSERTION [message #395831 is a reply to message #395824] Thu, 02 April 2009 14:34 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Good luck, I'll not be getting involved
Re: MULTIPLE DYNAMIC INSERTION [message #395881 is a reply to message #395824] Thu, 02 April 2009 23:59 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Krishna_dev wrote on Thu, 02 April 2009 20:21
dear pablolee. If the question had in fact been oversimplified, then would'nt you, in all your infinite wisdom, have simply answered it.

I totally agree with you. Your requirements are very very clear, so you have all the right to bash the people you ask for help if they dare to give you advice on how you stand more chance to get a good answer!
Now, here's the code you are asking for:
begin
  insert into your_table values ('COMPANY','LOCATION','SERVICE','FUTURE');
  insert into your_table values ('COMPANY','LOCATION','SERVICE1','FUTURE');
  insert into your_table values ('COMPANY','LOCATION','SERVICE2','FUTURE');
  insert into your_table values ('COMPANY','LOCATION','SERVICE3','FUTURE');
end;
/

Not what you meant? It does comply to what you asked for..
Re: MULTIPLE DYNAMIC INSERTION [message #396036 is a reply to message #395881] Fri, 03 April 2009 10:20 Go to previous message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
As would
begin
  insert into your_table values ('COMPANY,LOCATION,SERVICE,FUTURE');
  insert into your_table values ('COMPANY,LOCATION,SERVICE1,FUTURE');
  insert into your_table values ('COMPANY,LOCATION,SERVICE2,FUTURE');
  insert into your_table values ('COMPANY,LOCATION,SERVICE3,FUTURE');
end;

Previous Topic: Financial week and year problem
Next Topic: Prime Number Code
Goto Forum:
  


Current Time: Sat Dec 03 16:14:26 CST 2016

Total time taken to generate the page: 0.07655 seconds