立即与支持人员聊天
与支持团队交流

SQL Optimizer for SAP ASE 3.8 - 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

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

COBOL Conversion

SQL Scanner > SQL Conversion > COBOL Conversion

The COBOL conversion searches for three items within the syntax of a SQL statement that are allowed in the COBOL, but are not valid SQL syntax: 1) a dash or minus in a variable name, 2) comments in the middle of the SQL statement, and 3) the ]] (double right square bracket) as the concatenate symbol.

This conversion is only applied when the Scanner Job is added to the Job List in the SQL Scanner window using the COBOL option under the Source Code page in the Add Jobs wizard.

Conversion for variable name

If a variable name contains "-" minus sign, then it is replaced with "_".

Conversion for comment

If the 7th column of the line is an asterisk (*) then the complete line is recognized as a line comment.

Conversion for concatenate character

If ]] (two right square brackets) are used to concatenate column names, they are replaced with a +.

For example:

Original SQL statement

SELECT *

FROM EMPLOYEE  

* Get the department number       

WHERE EMP_ID >  :employee-id

AND    :name-job = ENAME]]JOB

After conversion

SELECT *

FROM EMPLOYEE   -- * Get the department number

WHERE EMP_ID >  @employee_id

AND    ENAME + JOB = @name_job

Note: If your COBOL file has tags at the beginning of the lines of code, you need to use the Number of characters to be skipped at the beginning of every line for all files option found on the SQL Scanner tab in the Preferences window.

 

Related Topic

相关文档

The document was helpful.

选择评级

I easily found the information I needed.

选择评级