DBSQLPR Issues Causing: SQLCODE = -20, SQLSTATE=42601 MESSAGE = SYNTAX-LAST TOKEN(S): <n>?
search cancel

DBSQLPR Issues Causing: SQLCODE = -20, SQLSTATE=42601 MESSAGE = SYNTAX-LAST TOKEN(S): <n>?

book

Article ID: 21763

calendar_today

Updated On:

Products

Datacom Datacom/AD Datacom/DB

Issue/Introduction

In a very simple SQL SELECT run by DBSQLPR JCL: 

SELECT *   
 FROM DIR_TABLE  
;  

the result is condition code 0020 due to a syntax error:

INPUT STATEMENT:   
SELECT *                                                       00520140  
 FROM DIR_TABLE                                                00520240  
;  
___________SQL ERROR SUMMARY START___________   
   
 SQLCODE = -20, SQLSTATE=42601   
 MESSAGE = BAD SYNTAX: <00520140>   
 WHEN THE ERROR OCCURRED, THE SYNTAX BELOW HAD BEEN PARSED:   
 SELECT * SELECT * 00520140                                                      00520140   
 FROM DIR_TABLE   
____________SQL ERROR SUMMARY END____________  

Environment

 

 

Cause

The SQLCODE = -20 error refers to some sort of syntax error in the submitted query.

Resolution

The syntax error is due to the sequence numbers in the source. The clue is in the "00520140" which shows that the input has sequence numbers in positions 73-80.

There is no need to edit and remove the sequence numbers. You can provide the DBSQLPR parameter INPUTWIDTH=72. INPUTWITH is used to limit the length of the input of the DBSQLPR control cards that are processed.

Additional Information

For more information about using the batch DBSQLPR program, refer to the documentation topic "DBSQLPR Utility—Execute SQL through Datacom/DB."

As always, please contact Broadcom support for Datacom if you have further questions.