Datacom SELECT INTO SQL DB21012E -20 syntax error in DBXMMPR COBOL preprocessor
search cancel

Datacom SELECT INTO SQL DB21012E -20 syntax error in DBXMMPR COBOL preprocessor

book

Article ID: 234429

calendar_today

Updated On:

Products

Datacom Datacom/DB

Issue/Introduction

A COBOL program using Datacom SELECT INTO SQL statement is getting syntax errors in  COBOL preprocessor DBXMMPR:

EXEC SQL
     SELECT ORG
           ,ORG_ID
           ,BOOK_ID
     INTO  :C-ORG
           ,:C-ORG-ID
           ,:C-BOOK-ID  
    FROM  CDE     
 WHERE ORG = :C-ORG     
    ORDER BY ORG DESC
    FETCH FIRST 1 ROW ONLY
END-EXEC.      

Error message:  

DB21012E ---- PREPARE STATEMENT FAILED (QHOST)
              BAD SYNTAX: <CDE WHERE ORG = :C-ORG ORDER >
              SQLCA-SQLCODE  = -20
              SQLCA-SQLSTATE = 42601

 

Environment

Release : 15.1

Component : DATACOM SQL

Resolution

The SELECT INTO statement is only meant to return one row so the ORDER BY and FETCH clauses are not valid syntax. 

Removing the two clauses resolves the syntax error.

Additional Information

See the Datacom documentation section Select-Into Statement