Chat now with support
Chat with Support

SQL Optimizer for SAP ASE 3.9 - User Guide

Introduction Tutorials Preferences Editor Functions SQL Information and Functions Performance Monitor SQL Inspector SQL Collector for Monitor Server SQL Scanner Index Advisor SQL Optimizer
SQL Optimizer Overview Optimization Engine Common Coding Errors in SQL Statements What Function Should l Use to Retrieve the Run Time? Unsatisfactory Performance Results SQL Optimizer Functions SQL Editor Optimized SQL Activity Log
SQL Worksheet SQL Formatter Database Explorer Code Finder Object Extractor SQL Repository Index Impact Analyzer Index Usage Analyzer Configuration Analyzer Migration Analyzer Abstract Plan Manager User-Defined Temp Tables SQL History Legal Information

External Parameter Conversion

SQL Scanner > SQL Conversion > External Parameter Conversion

For some source code, ? is used to define external parameters, therefore to enable unique referencing, the SQL Scanner adds a number so that each parameter has a unique name within the SQL statement.

For example:

Original SQL statement

SELECT EMP_ID

FROM EMPLOYEE

WHERE EMP_ID = ?

AND EMP_NAME = ?

After conversion

SELECT EMP_ID

FROM EMPLOYEE

WHERE EMP_ID = ?1

AND EMP_NAME = ?2

 

Related Topic

Local Variable Conversion

SQL Scanner > SQL Conversion > Local Variable Conversion

The local variable conversion converts SQL statements that are found in the application source code on one command line and also contain at least one "local variable" which will be replaced by the application before the SQL statement is sent to the server. The SQL Scanner encloses the variable name with @[variablename] and removes the concatenate character and the quotes surrounding the SQL text.

For example:

Original SQL statement before scanning

"" FROM EMPLOYEE WHERE EMP_ID > 100" + VEMPID + "SELECT

After conversion

SELECT FROM EMPLOYEE WHERE EMP_ID > 100@[VEMPID]

Note: The local variables in a scanned SQL statement should be treated as replacement or substitute variables rather than parameters. Therefore, you should hard code the values before you optimize the SQL statement. The reason for hard coding the values is that the local variables may be literals and when the application is run, these values are replaced before the SQL is sent to the database. That is why the SQL Scanner puts the variable within bracket to differentiate the local variables from the parameters.

 

Related Topic

Cursor Query Plan Conversion

SQL Scanner > SQL Conversion > Cursor Query Plan Conversion

When a SQL statement is used inside a cursor declaration, the query plan that Adaptive Server generates is different than the query plan that Adaptive Server generates for the same SQL statement used without a cursor declaration.

When the SQL Scanner finds that a SQL statement that has a FOR READ ONLY or FOR UPDATE clause and is used within a cursor declaration, the retrieval of the query plan is embedded in a cursor declaration so that the query plan matches the query plan that is used when the SQL statement is executed.

No change is made to the SQL statement.

Note: When you use the Send to SQL Optimizer function, the SQL for Cursor checkbox is automatically selected in the SQL Optimizer window.

 

Related Topic

Into Clause Conversion

SQL Scanner > SQL Conversion > Into Clause Conversion

For some front-end tools, the INTO clause of an SQL statement may be used for variable assignment which violates the syntax of the INTO clause. Therefore, an INTO clause in the SQL statement with more than one variable will be commented.

For example:

Original SQL statement

select EMP_ID,

EMP_NAME       

into a, b  

from EMPLOYEE  

After conversion

select EMP_ID,

EMP_NAME         /* into a, b */ /* Commented by SQL Optimizer*/

from EMPLOYEE  

 

Related Topic

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating