Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Error on Database VIew "*** ERROR *** WhereClause - invalid token" or "Syntax Error or Access Rule Violation: Unknown column 'prefix_u_field' in 'on clause'" - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Error on Database VIew "*** ERROR *** WhereClause - invalid token" or "Syntax Error or Access Rule Violation: Unknown column 'prefix_u_field' in 'on clause'"
KB0745484

Error on Database VIew "*** ERROR *** WhereClause - invalid token" or "Syntax Error or Access Rule Violation: Unknown column 'prefix_u_field' in 'on clause'"


4528 Views Last updated : Jan 28, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

One of these errors is appearing as an error in the UI or in the application logs:

  • '*** ERROR *** WhereClause - invalid token'
  • 'Syntax Error or Access Rule Violation detected by database: Unknown column 'prefix_u_field' in 'on clause')" is appearing in the application logs (where 'prefix_u_field' is present in one of the where/join clauses of the database view)
  • Where clause in view 'view_name' has an invalid field or a field that is not visible (SUBSTRING_INDEX)

Release

London and later.

Cause

The first error is produced when there is an unexpected character in the 'Where Clause' of a 'sys_db_view_table' record.  

The presence of a "." in a join table's where clause suppresses any further parsing of the condition.  This means that the 'prefix_field' syntax used in the join/where condition is not parsed and is interpreted as a literal field name, which does not exist, leading to the second error being reported.

The last error is caused because a SQL function has been introduced into the where/join clause and the presence of the '_' in the name is being parsed and being interpreted as if it was a 'prefix_field' combination, leading to the error as there is no view table with that prefix.  The use of SQL functions in the join/where clause is not documented as supported and their usage could cause the view not to execute.

Resolution

When you write the Where clause, add the field name to the Variable prefix of its table with an underscore. For example, in a Where clause, mi_id refers to the id field in the Metric Instance [metric_instance] table (mi) and inc_sys_id refers to the sys_id field in the Incident [incident] table (inc). Users will often incorrectly reference fields using the standard javascript syntax 'inc.sys_id', when the Where clause is expecting 'inc_sys_id'.

The Where clause supports these JavaScript conditional operators for comparing table fields:

=, !=, <, <=, >, >=, &&, ||

More information is available here: https://docs.servicenow.com/csh?topicname=t_AddATableToTheDatabaseView.html&version=latest


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.