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:
SELECT EMP_ID
FROM EMPLOYEE
WHERE EMP_ID = ?
AND EMP_NAME = ?
SELECT EMP_ID
FROM EMPLOYEE
WHERE EMP_ID = ?1
AND EMP_NAME = ?2
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:
"" FROM EMPLOYEE WHERE EMP_ID > 100" + VEMPID + "SELECT
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.
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.
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:
select EMP_ID,
EMP_NAME
into a, b
from EMPLOYEE
select EMP_ID,
EMP_NAME /* into a, b */ /* Commented by SQL Optimizer*/
from EMPLOYEE
© 2024 Quest Software Inc. ALL RIGHTS RESERVED. Nutzungsbedingungen Datenschutz Cookie Preference Center