Unable to parse simple query: version 14.10.01

Teradata Studio
Teradata Employee

Unable to parse simple query: version 14.10.01

When doing a simple query that includes the Year() function:

Select  col1, YEAR(col2) from Table1; the following message appears and will not allow the query to run:

"Parse Error Splitting Statement"

Thanks for your help!

16 REPLIES
N/A

Re: Unable to parse simple query: version 14.10.01

There's no YEAR function in Teradata or Standard SQL.

Depending on some ODBC settings this might still run (the ODBC driver replaces it with valid Teradata SQL), but it will fail if when it's part of a CREATE TABLE AS or CREATE VIEW, etc. statement and, of course, in any non-ODBC client.

Valid SQL is only:

EXTRACT(YEAR FROM col2)

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

As Dieter said, there isn't a YEAR function in Teradata. Your SQL appears to be using the ODBC escape function "YEAR". Studio uses JDBC to run queries. The JDBC driver supports JDBC escape functions. The SQL that uses JDBC the escape that is equivalent the ODBC escape you've shown is:

Select col1, {fn YEAR(col2)} from Table1;

This will still indicate a syntax error in the SQL editor. This is because this is not Teradata syntax. The editor doesn't parse the JDBC escape clauses. When you use the "Execute as Individual Statements" action (which the F5 function key performs), the statement(s) in the editor are split by parsing the contents of the editor to find the individual statements. If there is a syntax error, as is when using JDBC escape clauses, that parsing will fail and result in the message you've reported.

You can run SQL that contains apparent errors by using the "Execute All" action of the SQL menu (and the double-triangle toolbar button). This submits the text in the editor as a single transaction. All parsing will be done by the database.

Re: Unable to parse simple query: version 14.10.01

create table retail.employee_name

 (

 empid integer,

 empfirstname varchar(50),

 emplastname varchar(50),

 );

im using 14.0 version

Failed to execute sql

Reason:

Im getting parse error splitting statement

N/A

Re: Unable to parse simple query: version 14.10.01

If this is your actual DDL it's the ',' before the final ')'.

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

Durga, You should see red underscore in the SQL Editor to indicate you have a syntax error, as Dieter mentions above.

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

I just upgrded from Teradata Studio 14 to 15 and now I can't run a simple nested function, like this:

select lower(trim(message_id))

from...

I get a "Parse Error Splitting Statement". Anyone know how I can rectify this?

Thanks,

Wes

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

Wes, If you press F5 or Execute as Individual, the statement will be run through the parser. Do you see red indicating syntax errors? If  you want to execute anyway, choose the 'Execute All' option, when you right click in the SQL Editor. If you think there is a parsing bug, please include the complete SQL statement and we will look into it. Be sure you have chosen the correct version of Teradata database in the Connection profile.

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

Wes,

I do not see the Parse Error splititng statement message when running a statement that starts with your "select lower(trim(message_id)) from".

Is there anything in the editor underlined with red? If so, the parse error message will appear if you use Execute as Individual Statements. Is it possible that you have some sort of non-printing characters in your statement? Those could throw off the parser. Or are there some characters that might have come from a word processor that aren't valid SQL characters? For example, if you type apostrophes into Word, they might be converted to "smart quotes" that are not valid characters in SQL. If those are copied from Word and pasted into the SQL Editor, they will be copied as is which won't be valid.

Teradata Employee

Re: Unable to parse simple query: version 14.10.01

Thanks for your replies. I do not se any red underlined syntax errors. And no, I'm not pasting any SQL into Studio. I'm writing all my SQL in Studio and executing it there.

Also, I am running Studio against Aster, not Teradata. Sorry for leaving that out.

I have isolated the issue. I can do a lower(trim(emp_nm)) but not a trim(lower(emp_nm)). My coworkers can run this type of query successfully. This issue began when I upgraded from TD Studio 14 to 15.

Also, since updating to Studio 15 I've been getting more pop-up "parsing" errors and less descriptive errors in the SQL History. For example, if I'm include a comma after the final column definition of a CREATE TABLE statement I now get a Parsing error, rather than "syntax error at or near ')' ".

Any other ideas anyone? Thanks in advance for any suggestions or help.

Wes