Error in Prepare statment in SQLRPGLE

2430 pts.
Tags:
AS/400
SQLRPGLE
Hi Group, I'm having a problem with the prepare statement in SQLRPGLE. Here my code:
Eval      q_str = 'SELECT '                      
          + 'EMPCDE, EMPDEP, CLSS, STRYER, '    
          + 'SUBSTR(CHAR(UPDTTM),1,10) AS ENTRY '
          + 'FROM EMPMAS '        

If        vnum <> *BLANKS                
Eval      q_str = %TRIM(q_str)+ ' WHERE '
          + 'SRLNO = '+ vnum+' '       
EndIf                                 

c/Exec Sql                  
C+ PREPARE STAT1 FROM :q_str
c/End-Exec
VNUM field is defined in the display file as 13 length character field. But im getting error in the program like SQLCOD = -0000514. What would be the problem? Surey.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I think you need to declare a cursor for this before you attempt to declare the procedure.


c/exec SQL
c+ declare Stat1Cursor Cursor
c+   for Stat1


c/end-exec

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Splat
    This document provides an explanation of the various SQLCOD and SQLSTATE meanings: DB2 Universal Database for iSeries
    SQL Messages and Codes


    7,235 pointsBadges:
    report
  • Sureyz
    Phil,

    But in many examples i have seen that declare cursor was being placed after the prepare statement.

    Still in my situation, it is working without the if condition, like

    Eval      q_str = 'SELECT '                      
              + 'EMPCDE, EMPDEP, CLSS, STRYER, '    
              + 'SUBSTR(CHAR(UPDTTM),1,10) AS ENTRY '
              + 'FROM EMPMAS '

    c/Exec Sql C+ PREPARE STAT1 FROM :q_str c/End-Exec c/Exec Sql C+ DECLARE C1 SCROLL CURSOR FOR STAT1 c/End-Exec
    Which is working so perfectly.

    I guess the problem in the where condition.
    Can you please explain me how can i mention the number and character values in the where condition ?

    Surey.

    2,430 pointsBadges:
    report
  • Sureyz
    Anybody got an answer for this ? Still I'm not able to find the problem.

    Surey.
    2,430 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following