I've written simple SQL scripts before, but I'm no expert, so I'm not even sure that what I'm about to ask can be done. From a DB2 SQL script, I'd like to populate a table from the contents of a different table. Eventually, I am going to be bringing in data from other tables, but I just need to get the basics working first. I'm trying to do this from the DB2 CLP, executing a file.
From looking at manuals, I thought this might possibly work:
BEGIN ATOMIC
FOR ROW AS
SELECT OSN.SWOSNAME, OSN.SWPLATFORM FROM SASH1.LISTOSNAMES OSN
DO
INSERT INTO SASH1.VALIDOSES
VALUES (ROW.OSN.SWOSNAME, 'IBM', ROW.OSN.SWOSNAME, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Y', ROW.OSN.SWPLATFORM, NULL);
END FOR;
END
However, I'm getting the following error:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following
"SN.SWPLATFORM, NULL)". Expected tokens may include: "<delim_semicolon>".
LINE NUMBER=6. SQLSTATE=42601
It's fairly obvious that I don't know what I'm doing here. Is it possible to do something like this (populating a table from data in another table), without having to create SQL Procedures or Functions in the database?