dbTalk Databases Forums  

how to make a loop to do an insert for varchars

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss how to make a loop to do an insert for varchars in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John
 
Posts: n/a

Default how to make a loop to do an insert for varchars - 10-12-2010 , 06:49 PM






Hi folks,
let's say I want to do an insert of multiple rows, such as
"
insert into table ( id, column1 ) valuess ( idseq.nextval, 'abc');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'jfk');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'efg');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'bbc');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'bbb');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'xyz');
....
"

Is there a way I can do that in a for loop in oracle sql ?


Thanks for the tips.


John

Reply With Quote
  #2  
Old   
Michel Cadot
 
Posts: n/a

Default Re: how to make a loop to do an insert for varchars - 10-12-2010 , 11:58 PM






"John" <chunji08 (AT) gmail (DOT) com> a écrit dans le message de news: 4e595876-bcd7-4f57-a0f8-16f59be3f3c4...oglegroups.com...
Quote:
Hi folks,
let's say I want to do an insert of multiple rows, such as
"
insert into table ( id, column1 ) valuess ( idseq.nextval, 'abc');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'jfk');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'efg');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'bbc');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'bbb');
insert into table ( id, column1 ) valuess ( idseq.nextval, 'xyz');
...
"

Is there a way I can do that in a for loop in oracle sql ?


Thanks for the tips.


John



If the data in the second column does not follow a rule
(maybe the random one) how could you do it in a loop?

If you want to do it in a single statement, have a look at INSERT ALL.

Regards
Michel

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.