My first guess would be commitment control.
I can get it to work using either prepared or direct SQL. But only when I
have commitment control off.
EXEC SQL set option commit=*none;
From: Thomas Garvey ; Thomas Garvey
Sent: Wednesday, March 20, 2013 3:20 PM
To: 'RPG programming on the IBM i (AS/400 and iSeries)' ; 'Midrange Systems
Subject: Differences between STRSQL and embedded SQL
I'm working on an embedded SQL command that would create a temporary file of
random records from another file. The SQL statement works when executed
interactively using STRSQL, but fails with SQL0117 (Statement contains wrong
number of values).
Here's the SQL statement...
create table qtemp/F3003 as (select IREFFF,rand() as idx from QGPL/F3003
order by idx fetch first 380 rows only) with data
So, F3003 exists as a table with 50 fields, and some 40,000 records. This
statement should create a new table in qtemp with 380 records, consisting
only of the IREFFF field and a random number, cast as field idx.
It works fine interactively. But when this statement is performed in RPGLE
embedded SQL (as a string, which is then PREPAREd and EXECUTEd), I get the
SQL0117. When I look up the SQL0117 explanation, I don't see that any of
the conditions exist.
Anyone have any ideas? And I always thought: if I could do it
interactively, I could certainly do it in embedded SQL.