Parser Errors

This section includes error messages for the Adaptive Server Parser.




Error 102

Severity

15

Message text

Incorrect syntax near '%.*s'.

Explanation

This error occurs when Adaptive Server detects a syntax error in a Transact-SQL command or query.

This error can occur when:

Action

Check the spelling and syntax of the command specified in the error message. If it is wrong, correct it in your Transact-SQL statement and run it again.

You can invoke an editor such as vi from isql to edit a SQL statement or statements. However, for the statements to execute, you have to enter the command termination string (usually “go”) after you return to isql. If you include the command termination string in the editor, then save the file and return to isql, the statement will not execute. If you enter the command termination string again after returning to isql, you get the following error (“vi” is the editor in this example; you may be using a different editor):

1> vi

1> select * from sysmessages where error = 102
2> go
3> go

Msg 102, Level 15, State 1:
Server 'REL1002_NAME', Line 2:
Incorrect syntax near 'go'.

If you are not sure that your query contains a reserved word, use the following query to see a complete list of reserved words:

1> select name from spt_values where type = "W"
2> go

Additional information

Refer to the documentation for the utility you are using for correct syntax information. Some examples are:

Versions in which this error is raised

All versions




Error 107

Severity

15

Message text

The column prefix '%.*s' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.

Explanation

Tables are specified in the FROM clause of a query. When Adaptive Server parses a query prior to execution, the name by which it knows the table is in the from clause: the table name if given alone, or a correlation name (alias) if one was specified. For example, in the query:

1> select c.cityname from cities c
2> go

the table is known as c for purposes of the query. Names specified in other clauses refer back to this name to determine what table is intended.

Error 107 can be raised:

These restrictions apply to views as well as real database tables.

Action

Check your query for these errors and take corrective action:

  1. Check for a typing error like the following:

    1> select * from titles
    2> where title.code = 205
    3> go
    

    Msg 107, Level 15, State 1:
    Server 'mfg', Line 2:
    The column prefix 'title' does not match with a table name or alias name used
    

    The column name in the where clause should be titles.code. Likewise this statement is incorrect:

    1> select t2.title_id from titles t1
    

    The correct statement is:

    1> select t1.title_id from titles t1
    

  2. Ensure that correlation names are used correctly. For example, this statement is incorrect:

    1> select title_id 
    2> from titles t
    3> where titles.type =  "french_cook"
    

    The where clause can not use titles, because the from clause defines a correlation name for the table. The correct query is:

    1> select title_id 
    2> from titles t
    3> where t.type = "french_cook"
    

Additional information

Note the special case where a query that returns Error 107 may report no error when the same type of correlation is used in a subquery. For example:

1> select * from mytable
2> where columnA =
3> (select min(columnB) from mytable m
4> where mytable.columnC = 10)

This query is a correlated subquery, and mytable.columnC refers to the outer table mytable. This query works because the same table is referred to in the inner and outer queries. In general, however, correlated subqueries can also generate Error 107 when correlation names are used incorrectly.

Versions in which this error is raised

All versions




Error 195

Severity

15

Message text

’%.*s’ is not a recognized %S_MSG.

Explanation

Error 195 is raised when a query contains illegal syntax; more specifically, it is raised when the Adaptive Server parser expects a specific syntaxt (such as a particular command, keyword or punctuation mark) but instead encounters some other syntax or encounters missing text.

Error 195 is raised with the following states:

State

Meaning

1

Invalid create procedure option.

2

Invalid timestamp keyword on writetext.

3

Invalid log keyword on writetext.

4

Invalid shutdown option, invalid trace keyword on kill, or invalid option on set lock.

5

Invalid set option; covers miscellaneous options that are set to "on" or "off"

6

Invalid option on set offset.

7

All other invalid set options

8

Invalid option on set statistic.

15

Invalid quiesce database begin option

16

Invalid quiesce database end option

The following common query errors may raise the 195 message:

Action

Check the query syntax; the state of the error can be helpful in locating the source of the problem in a complex query.

Check the semantics to make sure that the keywords or options used in the query are valid where they are used in the query.

If Running xp_cmdshell

If the 195 error was raised when you attempted to run xp_cmdshell, check for invalid syntax and check the parameters that were supplied to the procedure. Combinations of single and double quotes can make it impossible for the command to be parsed; replace each double quote (") with two single quotes (’’) and retry.

If Using CIS

If the 195 error was raised when you queried an object in a remote server using Component Integration Services (CIS): your query may be using T-SQL syntax which is not understood by the (non-Sybase) remote server. To correct this, use the sp_passthru stored procedure, which allows you to pass a SQL statement using syntax native to the remote server.

For example:

sp_passthru ORACLE, "select date from shiptable",
@errcode output, @errmsg output, @rowcount output,
@shipdate output

Additional information

Refer to the Reference Manual for more information about sp_passthru.

Versions in which this error is raised

All versions