开发者

Apache Derby Lexical Error on #-sign?

I'm programmatically transferring data between a DB2 server and an Apache Derby (JavaDB) server.

The DB2 server has a number of tables w开发者_运维问答ith column names that include the pound sign (#) character. However, when trying to create tables in Derby:

CREATE TABLE LIBNAME.TABNAME  
(COL# decimal(3,0),  
REC# decimal(5,0),  
DESC char(30,0),  
SDSC char(10,0));

I get the following error:

ERROR 42X02: Lexical error at line 1, column 38. Encountered: "#" (35), after : ""

The Derby Reference Manual is no help; the given explanation for error code 42X02 is simply <value>

It's a simple task to remove the pound sign from the column names for Derby and then add it back for DB2, but I'd like to avoid it if I can.

Does anyone happen to know if Derby simply doesn't allow the # character (and why?) or if I'm doing something wrong...


According to the Derby reference manual (Rules for SQL92 Identifiers):

Ordinary identifiers are identifiers not surrounded by double quotation marks. Delimited identifiers are identifiers surrounded by double quotation marks.

An ordinary identifier must begin with a letter and contain only letters, underscore characters (_), and digits. The permitted letters and digits include all Unicode letters and digits, but Derby does not attempt to ensure that the characters in identifiers are valid in the database's locale.

A delimited identifier can contain any characters within the double quotation marks. The enclosing double quotation marks are not part of the identifier; they serve only to mark its beginning and end. Spaces at the end of a delimited identifier are insignificant (truncated). Derby translates two consecutive double quotation marks within a delimited identifier as one double quotation mark-that is, the "translated" double quotation mark becomes a character in the delimited identifier.

So, COL# appears to be invalid as an ordinary identifier because of the #. "COL#" would probably be valid as a delimited identifier, but I haven't tested this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜