Running AS/400 query

405 pts.
Tags:
AS/400
SQL
SQLCODE -104 while preparing statement in SQL . Eval Sqlstmt1= 'Insert Into' + ' ' +
%Trim(WRKTLIBR) +'/' +%Trim(WRKFILE) +
' '+'(Select * from '+ %Trim(WRKLIBR) +
'/' + %Trim(WRKFILE) + ' ' + 'A' + ' '
+ 'Where Exists (Select * from CSTBYUNQL1 B '
+' Where B.Compny = A.' +%Trim(WRKCMP)
+ ' and '+
'B.Customer# = A.' +%Trim(WRKCST) +' and '+

'SUBSTR(LIBRARY,7,4) = ''' + %trim(WRKFRLB)+
''' ))'
Please let me know all possible reasons, Interactively running this query getting executed, then I tried with Exec it isa executed. The scenario is for one record I'm getting this error for another I'm getting SQLcode as 100. Need help urgently.
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  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.
  • philpl1jb

    I would suspect that it's the value of Sqlstmt1

    It would be better to see the actual value.

    If you had a dump or used the debugger or a dsply right after that field is loaded in the EVAL, I think the problem would be more obvious. 

    Sqlcode 104-  is an ILLEGAL SYMBOL "token".

    Also in a dump there are a series of SQL fields describing the issue further.

    54,090 pointsBadges:
    report
  • bvining
    I agree with Philip in that seeing the actual value of SQLStmt1 will probably make all the difference in the world. Given that in one case you're getting a SQLCode of 100 (a good statement) while in the other you're getting a SQLCode of -104 (a bad statement) my first suspicion is that in the -104 case you might have a blank value for one of the fields you are using %trim on. That would certainly cause an invalid SQL statement, and would likely lead to an invalid token situation (as you would be missing "something" in the expression.

    Just guessing,
    Bruce Vining
    7,070 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.

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

Following

Share this item with your network: