Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:22:56+00:00 2026-06-05T06:22:56+00:00

I’m able to connect to IMS segments and do sql queries with primary key

  • 0

I’m able to connect to IMS segments and do sql queries with primary key in where clause and select * queries. But whenever I’m trying to do a select with another column I get a lexical error.

Select * from table where column-name='something'

This would give me the exception ‘Exception in thread “main” com.ibm.ims.jdbc.TokenMgrError: Lexical error at line 1, column 42. Encountered: “-” (45), after : “”‘. If I have the column name as first-name, then the lexical error would occur at position of hyphen in first-name. I’ve tried doing this via Prepared Statement and it still does not work.

After doing the following changes, I still get exceptions.
Select * from table where ‘column-name’=’something’
Caused by: com.ibm.ims.jdbc.ParseException: Encountered ” “\’column-name\’ “” at line 1, column 36.
Was expecting one of:
…
“(” ..
.

Select * from table where column+’-‘+name=’something’
Exception of lexical error with ‘-‘

Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \ ), this is the message I get when I’m trying for adding backticks or some escape sequences.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:22:57+00:00Added an answer on June 5, 2026 at 6:22 am

    In most dialects of SQL the - character is not a legal character in an (undelimited) identifier. For example, the SQL-92 spec says:

         <identifier> ::=
              [ <introducer><character set specification> ] <actual identifier>
    
         <actual identifier> ::=
                <regular identifier>
              | <delimited identifier>
    
         <SQL language identifier> ::=
              <SQL language identifier start>
                [ { <underscore> | <SQL language identifier part> }... ]
    
         <SQL language identifier start> ::= <simple Latin letter>
    
         <SQL language identifier part> ::=
                <simple Latin letter>
              | <digit>
    

    (TL;DR – letters, digits and underscores)

    (I hesitate to say all dialects, because the SQL language bestiary is rife with deviations from the various standards.)


    Does this apply to %,_ too, I can see some solutions which are allowing escape sequence with %,_. The solutions mentioned still don’t work for hyphen. Reference: myitforum.com/cs2/blogs/jnelson/archive/2008/08/27/121684.aspx

    First, the reference you found applies to escaping in string literals, not in identifier names. It does not apply to THIS problem. (And does it apply to your SQL dialect?)

    Second, according to the syntax above, underscores should be allowed in identifiers … if the SQL dialect you are using is following the standard.

    Third, the standard talks about “delimited identifiers” (using double quote characters as the delimiter). I don’t know how widely supported this is in real SQL dialects, but I imagine that even when it is there are restrictions on what characters you can use … and other caveats.

    Fourthly, irrespective of what the SQL standards say, the documented syntax for the particular dialect you are using is what you should be looking at. (I was only using it to illustrate the general properties of SQL … in the absence of any details of the dialect you are actually using. “Mainframe” SQL could be many things.)

    Finally, you will be better off not trying to use “funky characters” in identifiers. Use Latin letters, digits and underscores … and if your SQL dialect doesn’t even allow that, then stick to what it does allow.

    And read the vendor SQL documentation!!!

    @Rob I’ve tried both and it did not work.

    Well read the vendor SQL documentation carefully. It should tell you what will work. And if it says the you can’t do it … well, you can’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.