Environment: INFORMIX 9.50C1, AIX 6.1
The closest analogy to what I am trying to do is a Mail Merge. Here is the scenario:
One table (CLIENTS) has a large number of columns (72 columns). The table contains client data, and the columns represent various attributes of the client.
CLIENT_ID RPQ_ID Attrib2 Attrib3 ... Attrib71
The unique key on the table is the client id: CLIENT_ID, which is a 12-character alphanumeric field. All other columns do allow duplicates.
One row in the CLIENTS table is set up as a template for a new set of clients.
CLIENT_ID RPQ_ID Attrib2 Attrib3 ... Attrib71
TEMPLATE_017 000000 London017 CLS12 ... 12
I have second table (TMP_IMPORT) that contains a list of new client ids with one additional non-unique attribute (RPQ ID). The import list has ~2000 rows.
CLIENT_ID RPQ_ID
GPR3344 HG777
JND4111 JL888
JPS3172 JL888
PAP2171 JL888
...
The task is to perform the equivalent of a mail merge: add the 2000 new rows to the CLIENTS table, using the client_id and rpq_id values from TMP_IMPORT and all the other columns from the template row.
The expected result in table CLIENTS is
CLIENT_ID RPQ_ID Attrib2 Attrib3 ... Attrib71
TEMPLATE_017 000000 London017 CLS12 ... 12
GPR3344 HG777 London017 CLS12 ... 12
JND4111 JL888 London017 CLS12 ... 12
JPS3172 JL888 London017 CLS12 ... 12
PAP2171 JL888 London017 CLS12 ... 12
...
This is all taking place within a large corporation with very little flexibility as far as access control, execution rights, etc. The solution must use straight SQL, without shell scripts, procedures, ot third party libraries.
Also, please: no enumeration of the columns. One of the common solutions I've seen is to join the tables and specify the source of each data column, as in
select TMP_IMPORT.CLIENT_ID, TMP_IMPORT.RPQ_ID, CLIENTS.Attrib2, CLIENTS.Attrib3, ..., CLIENTS.Attrib71 from TMP_IMPORT, CLIENTS ...
This would be reasonable for a table with just a few columns, but I hope someone has a more elegant solution.
Thank you!