Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Repetitive insert statements

Re: Repetitive insert statements

From: magpies <-_->
Date: Tue, 19 Nov 2002 22:20:38 +0800
Message-ID: <ardhb7$cr311@imsp212.netvigator.com>


you can :-

insert into tb values

   select &1, &2, &3 from dual
   UNION
   select &4, &5, &6 from dual
   UNION
   :
   :

"CH." <chattrin_h_at_hotmail.com> wrote in message news:7242ea7b.0211181828.6332a5b6_at_posting.google.com...
> Hi,
>
> I'm working on a database assignment and ran into a problem. I have a
> table and I need to insert 50 records into it. Right now I have 50
> insert statements that enter all of the data correctly but I just
> found out that I cannot do it that way. I'm suppose to have just 1
> insert command and execute run to enter each value (What a great way
> to insert data!). Please look below for an example.
>
>
> create table tb(id char(4), col1 char(5), col char(5));
>
> SQL> insert into tb values (&id, &col1, &col2);
> Enter value for id: 1234
> Enter value for col1: 12345
> Enter value for col2: 78905
> old 1: insert into tb values (&id, &col1, &col2)
> new 1: insert into tb values (1234, 12345, 78905)
> SQL> run
> 1* insert into tb values (&id, &col1, &col2)
> Enter value for id: 2345
> Enter value for col1: 13241
> Enter value for col2: 43211
> old 1: insert into tb values (&id, &col1, &col2)
> new 1: insert into tb values (2345, 13241, 43211)
> SQL>
> SQL> run
> 1* insert into tb values (&id, &col1, &col2)
> Enter value for id: 7894
> Enter value for col1: 74125
> Enter value for col2: 96325
> old 1: insert into tb values (&id, &col1, &col2)
> new 1: insert into tb values (7894, 74125, 96325)
> SQL>
>
> Is there a way to put everything into a script? I'd appreciate any
> hint or pointer or example. Please help.
>
> Thank you
> Chatt H.
Received on Tue Nov 19 2002 - 08:20:38 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US