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
You have sqlstmt
defined as 100 characters maximum and with the where clause your string is over 100 characters long. Your SQL statement is getting truncated and that's why its not working. I suspect you know how to fix this but just for completeness, the solution is the following:
D sqlstmt s 500a varying