Re: Getting Line Number Error in a query
Posted in 2005
"Jose J. Sanchez" <jesussanchez@iteso.mx> wrote:
> How can i get the line number or position of a syntax error when i execute
a query
>
> lets say for example:
>
> SELECT *
> FROM nonexistent_table
> WHERE id = 1>
> i have an error on line 2,
>
> is there a way to get this information from informix??
You've got a single statement regardless of how many lines it takes to write
it out. If there is a way to get the "line number" of the problem with a
SQL statement *as typed* as opposed to as evaluated by the engine, I've
never heard of it. How are you executing the query?
You have a chance at finding out the position of the error if you are using
some of the Informix tools (DB-Access or 4GL, for example). When editing a
problematic statement, you will get very close to, if not right on, the
error. Either the cursor will be positioned for you, or the error (or error
file) will indicate the position with a carat (^). You might also get what
you need from the sqlca record. It depends on the tool that you are using,
but the ones that I've worked with will get you, at the very least, close.
In addition, the error numbers and messages returned are generally very
specific. If you are using DB-Access, for example, you would get an error
such as "206: The specified table (nonexistent_table) is not in the
database." A problem with a column name would return something like "217:
Column (id) not found in any table in the query...". If, on the other hand,
you were executing the statement from within a 4GL program, you could
capture the same error codes by evaluating sqlca.sqlcode. Other languages
offer other ways of capturing the error.
Without more information about how you are executing the query, this is
about all I can tell you.
--
June Hunt