These are two valid examples that are running.
The first is a string with sum.
The second is a dadena with insert.
SELECT QAPTS1Y3X.ASIEN, SUM(QAPTS1Y3X.DB), SUM(QAPTS1Y3X.HB)
FROM QAPTS1Y3X
GROUP BY QAPTS1Y3X.ASIEN
CAD='INSERT INTO TPSUFORPRINT (LOSVAL,ACT3, ACT1, CL10, ORDEN, ACL5) SELECT',
' '"'"LOSVALCAL"'"' AS VAL7, '"'"ACT3R"'"' AS VAL1, '"'"ACT1R"'"' AS VAL2, '"'"ACT3R"'"' AS VAL3, 1 AS VAL4, '"'"ACT1R"'"' AS VAL5 FROM CATALIZA'
RC=DBERUNSQL(CAD)
In the chain with insert, note that says--- from cataliza-----
Cataliza is a table created only to execute the insert command. For all the insert comands in your sqls.
I have this table created as two columns of text of 254 characters, without indices, but I think this is the least.
I work with DBF tables.
Saludos