DB006001 C-4M330: Unrecognizable token on XMLSERIALIZE Function
search cancel

DB006001 C-4M330: Unrecognizable token on XMLSERIALIZE Function

book

Article ID: 227997

calendar_today

Updated On:

Products

IDMS

Issue/Introduction

Using the IDMS XMLSERIALIZE function in a SELECT statement gives a syntax error:

SELECT D.DIV_CODE                                                             
      ,XMLSERIALIZE(CONTENT                                                   
       XMLELEMENT(NAME DIVCODE, DIV_CODE))                         
FROM DEMOEMPL.DIVISION D;    

*+ Status = -4       SQLSTATE = 42600        Messages follow:
*+ Syntax error in line 3 at column 42, token = )
*+ DB006001 T721 C-4M330: Unrecognizable token

 

Environment

Release : 19.0

Component : CA IDMS SQL

Resolution

The XMLSERIALIZE function is missing the 'AS string-data-type' clause. See the documentation section XMLSERIALIZE-function 

XMLSERIALIZE ─── ( ───┬── CONTENT ──┬────────────────────────►
                          └── DOCUMENT ─┘

 ►──── XML-value-expression ── AS string-data-type ─── )
 
 string-data-type
Must be one of the character data types of data type: CHAR(n), CHARACTER(n), VARCHAR(n), CHAR VARYING(n).

So depending on the data type and length code it like this:

SELECT D.DIV_CODE                                                             
      ,XMLSERIALIZE(CONTENT                                                   
       XMLELEMENT(NAME DIVCODE, DIV_CODE) AS CHAR(3))                         
FROM DEMOEMPL.DIVISION D;