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.
"" 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.
into a, b
EMP_NAME /* into a, b */ /* Commented by SQL Optimizer*/
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.
If a variable name contains "-" minus sign, then it is replaced with "_".
If the 7th column of the line is an asterisk (*) then the complete line is recognized as a line comment.
If ]] (two right square brackets) are used to concatenate column names, they are replaced with a +.
* Get the department number
WHERE EMP_ID > :employee-id
AND :name-job = ENAME]]JOB
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.