I have a simple insert statement I want to execute using sqlrpgle. I build the statement first depending on what variables are empty and then want to use exec sql to do the insert. This does not work.
But entering the same insert statement with subquery in STRSQL works fine.
I have broken down the sql statement to its simplest version for this question.
Here is the SQLRPGLE code snippet

And here is where I enter the same statement in STRSQL

Any Assistance would be greatly appreciated.
**EDIT
This only happens when I add a where clause, which is essentially what I need and why I am trying to do it using sqlrpgle. Statements like
sqlstmt = 'insert into jallib/sbrmrpt (shscdt, shcmdt) ' +
'select shscdt, shcmdt ' +
'from r50files/sbschd ';
and
sqlstmt = 'insert into jallib/sbrmrpt (shscdt, shcmdt) ' +
'values (10, 10) ';
All work just fine, once a where clause is added to the subquery is where it does not work in the RPG code but in STRSQL