Reputation:
Is it possible to insert in one single query multiple values into a table ? .
I have declared this table
declare global temporary table CFVariables
(
CF varchar(255)
)
with replace ;
then i inserted values into the table
INSERT INTO qtemp.CFVariables ( CF ) VALUES
('F01' ), ('T01' ), ('U01' ), ('CIP' ), ('L01' )
Is it possible to not insert the values in qtemp.CFVariables table this way ? but like In ('F01' , 'T01' , 'U01' , 'CIP' , 'L01' )
Then , i declared my second table :
declare global temporary table xVariables
(
CFC numeric(3),
CF varchar(255)
)
with replace ;
In this part i'm having a problem to insert into my table xVariables
I tried to use this to insert multiple values
INSERT INTO qtemp.xVariables ( CFC, CF ) VALUES
( 1, (select CF from qtemp.CFVariables ))
My query field because i'm inserting more then one row to the table . How can i achieve this ?
Upvotes: 0
Views: 325
Reputation: 76444
Try running an insert-select:
INSERT INTO qtemp.xVariables ( CFC, CF )
select 1, CF from qtemp.CFVariables
To restrict the records to be inserted, you will need to do something like this:
INSERT INTO qtemp.xVariables ( CFC, CF )
select 1, CF
from qtemp.CFVariables
where CF in ('F01' , 'T01' , 'U01' , 'CIP' , 'L01' )
Upvotes: 0
Reputation: 1321
Try
INSERT INTO qtemp.xVariables ( CFC, CF ) SELECT 1 AS CFC,CF from qtemp.CFVariables;
Upvotes: 1