× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 12-Nov-2014 10:47 -0600, Hoteltravelfundotcom wrote:
the following SQL code works up until the last statement
(Select Coalesce(SUM(OdQty#),0)

What was given [but snipped] as the "following SQL" did not start that statement with a left parenthesis. As a subquery, the above SELECT statement is missing the closing parenthesis, and minimally needs to have added a FROM clause to be valid; as a full-select the prefix of the left-parenthesis should be omitted, plus the same issue with the incomplete statement [lacking a FROM clause] remains to be corrected.

then it gives this message:

'SQL0199 Keyword Select Not Selected. Valid Tokens: For Use Skip Wait
With Fetch Order Union Except Optimize'

can you explain this issue to me?

<<SNIP poorly formatted SQL>>

The issue seems IMO to be, generically, that poorly formatted code is difficult to decipher. And that such difficulty, then causes some errors that get issued by the parser\syntax-checker of the language, to be less-than-obvious, with regard to how the issue might be resolved.

If indeed the claim that "code works up until" is valid [seems to be so; the "SELECT COUNT(*) ... 'SPC')))" at least appears to be valid syntactically], and given the clear implication that there is another statement [i.e. "until the last statement"], then a conspicuous potential origin for the error is that there are two statements; the first is a complete and valid statement, but the second statement is both incomplete and should be distinct from the former statement.

Thus the problem would seem to be that two distinct SELECT statements are being passed to a utility, and that utility is asking the SQL to parse the two SELECT statements as one statement, such that the two statements must be separated by whatever is the expected statement-separator for whatever is the [unstated] utility being used.

So effectively the resolution could be one of:

• If the utility is capable of accepting only one statement, then simply omit the "last statement"; compose the second\last statement separate from the first statement, and pass that corrected\completed statement on a separate request of\to the utility.
• If the utility is capable of accepting multiple statements, then precede the second\last statement with the statement-separator character(s); that is typically going to be the single semicolon character. Of course for the second statement to be functional, that second\last statement must be corrected\completed, else that will fail with a syntax error [minimally for the lack of a FROM clause].

Otherwise if there should be just one statement, then that statement is ill-formed and must be corrected. About the only correction I can think there would be to form just one statement, is with the addition of one of the set-based clauses to separate the two sub-selects [e.g. UNION or EXCEPT]; instead of a statement separator that would identify the two SELECT statements as separate requests\statements.

P.S. I see from a followup reply the FROM-clause issue should be resolved. So as stated above, either the single-statement needs to be properly formed as just the one statement, or the two statements need to be distinguished as such.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.