1

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 enter image description here

And here is where I enter the same statement in STRSQL enter image description here

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

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

2 Comments

Lol. No problem. It just makes me feel a little better that I only made this mistake in front of a coworker and not on StackOverflow. ;)
debug is your friend!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.