Hi,
I have several DB2 tables with the same fields and structure.
My program reads a sequential file and decides which of the tables to use in the insert statement.
So I need to find a way to use a dynamic table name within the INSERT operation.
I’m looking for something like :
INSERT INTO DYNAMIC_TB_NAME
(…)
VALUES
(…)
thank u all for any suggestion.
Have you thought about using copycode with dynamic overrides?
The main program:
DEFINE DATA LOCAL
1 #DYNAMIC-NAME (A32)
...
IF ...
MOVE 'DYNAMIC_TB_NAME' TO #DYNAMIC-NAME
...
INCLUDE COPYCODE #DYNAMIC-NAME
The copycode:
INSERT INTO &1&
(...)
VALUES
(..)
Hi,
Thanks for your suggestion. It seems to be a good & simple one.
just one comment about it,
the INSERT statement can’t be used if the table name is not defined beforehand, at compilation time, so I can’t use a local variable for containing the table name, but I don’t really need to.
thank you very much for your fast and helpful reply !