Validating SQL and XQuery statements

You can validate the syntax of SQL statements and XQuery statements in the SQL and XQuery editor. You also can validate the table, column, and stored procedure references in SQL statements.

You can validate existing SQL and XQuery statements when you open the script that contains the statements in the SQL and XQuery editor. You also can validate SQL and XQuery statements while you are creating them or editing them in the editor.

Before you begin

About this task

The syntax in SQL statements and XQuery statements is validated by parsing the statements to determine whether keywords and their location in the statements are valid. By default, parsing is based on the type of database that the script is connected to. You can change the parser to use for validation; for example, if you plan to export a script for use in another supported database. If you have disconnected a script from its database, you can select the parser to use for validation.

Table, column, and stored procedure references are validated only in SQL DML statements. The validation process determines whether the following conditions are met:
  • Tables that are referenced in the SQL statements exist in the connected database
  • Referenced columns exist in the table that they are associated with
  • Stored procedures that are called in the SQL statements exist in the connected database

Procedure

To validate SQL statements and XQuery statements in the SQL and XQuery editor:

  1. Optional: If you want to validate statements based on a specific database type that does not match the type used for your connection, change the parser to use for validation:
    1. Open the Validation tab.
    2. Select a validation option.
  2. To validate the syntax of the statements, right-click in the editor, and then select a validation option.
    • To validate the syntax of the statements for the connection that is selected in the Configuration tab, select the Validate statement syntax for current configuration option.
    • To validate the syntax of the statements for a different data server type, select the Validate statement syntax option. Then, select a data server type from the list.
  3. Optional: To validate table, column, and stored procedure references in the SQL DML statements in the script, do one of the following actions:
    • In the Command pane, click the Validation tab, and then select the Validate database object references check box.
    • Right-click in the editor, and then select Validate Database Object References.

Results

Validation errors are shown in the SQL and XQuery editor marker bar.

Feedback