Reputation: 429
I want to Insert values multiple times like, I have PartNo and Quantity if I enter PartNo as Fibre and Qty = 3 then It should fill in 5 times as:
PartNo Inventory_Qty
Fibre 1
Fibre 1
Fibre 1
Please help me how to write a query for this.
Upvotes: 0
Views: 726
Reputation: 1720
In only one sql command:
INSERT INTO table1 ('PartNo', 'Inventory_Qty')
SELECT 'Fibre', 1 FROM DUAL
UNION ALL
SELECT 'Fibre', 1 FROM DUAL
UNION ALL
SELECT 'Fibre', 1 FROM DUAL;
or differently (but not supported by Oracle, thanks Lukas Eder)
INSERT INTO table1 ('PartNo', 'Inventory_Qty')
VALUES ('Fibre', 1),
('Fibre', 1),
('Fibre', 1);
Upvotes: 2
Reputation: 40499
With a table such as
create table tq84_insert_test (
partNo varchar2(20),
inventory_qty number(4)
);
you migh try
insert into tq84_insert_test
select
'Fibre', 1
from
dual
connect by rownum <= 3;
Since I'm not sure if you want to insert 3 or 5 records, I assumed 3. But you might want to change the 3 in the insert statement accordingly.
Upvotes: 3