SQL Analyzer - 3.8


Compatibility: v2 v3 Express
What's new? Release Notes
ID: com.castsoftware.sqlanalyzer

Description

The SQL Analyzer provides support for database technologies using the ANSI SQL-92/99 language. This extension uses the Universal Analyzer framework and is intended to analyse DDL, DML and SQL exports for a large variety of SQL variants:

  • This extension provides source code analysis support for DDL and DML source files using an over language of the various SQL variants.
  • See Supported File Extensions below for the list of supported files.

In what situation should you install this extension?

  • If you need to analyze the SQL server part compliant with ANSI SQL-92 / 99 of your client/server application

Supported file extensions

The following table summarizes the source file extensions managed by the SQL Analyzer by default. Other file extensions could be used, upon manual configuration (within CAST Console). You can also have a look to Database File Discovererin order to understand which one of the file extensions are taken in account when a SQL project is added. 

File

Extension

Mandatory/Optional

Note

SQL source files

.sql

.sqlt

.ddl

.dml

.plsql

.pgsql

.mysql

Mandatory

DDL / DML files

You should deliver at least one of the listed extensions.

CAST generated Files

.uaxdirectory

.src 

.src files are SQL sources files generated with CAST Database Extractor. Supported for compatibility reasons only.

IBM Db2 for i Logical File

.lf

.lf38

IBM Db2 for i View in DDS format
IBM Db2 for i Physical File

.pf

.pf38

IBM Db2 for i Table in DDS format
CAST SQL Table Size File .sqltablesize Optional See SQL Analyzer - working with XXL or XXS tables.
CAST Data Sensitive File .datasensitive Optional See SQL Analyzer - RDBMS Table Sensitive Data.
Additional SQL source files

.bdy

.db2

.fnc

.pck

.pkb

.pkg

.pks

.plb

.pls

.spc

.tab

.tpb

.tps

.trg

.trigddl

.tsql

.udf

.viewddl

.viw

.vw

Optional

DDL files

Those files are not recognised by Database File Discoverer  but if you have at least one mandatory file in the analysis root folder, the SQL Analyzer will analyze them.

Unsupported files extensions

Some other file extensions could potentially have SQL statements, e.g. : *.inc, *.prc or *.vue. The product is matching them with PHP language for *.inc, JCL language for *.prc and VueJS for *.vue. That’s why they are not listed above. If you’re sure they contains valuable SQL statements, simply change the extension from inc/prc/vue to sql.

Vendor compatibility matrix - official support

Icon Vendor Version Supported?

IBM Db2 for LUW

Up to version 11.x

(tick)

IBM Db2 for z/OS Up to version 12 (tick)

IBM Db2 for i Up to version 7.5 (tick)

IBM Informix Up to version 14.x (tick)

MariaDB Up to version 10.x (tick)

Microsoft SQL Server Up to version 2022 (tick)

MySQL Up to version 8.x (tick)

Oracle Server Up to version 23ai (tick)

PostgreSQL Up to version 17.x (tick)

SAP ASE (formerly known as Sybase ASE) Up to version 16 (tick)

SQLite Up to version 3.x (tick)

Teradata Up to version 16 (tick)

CockroachDB Up to version 24 (tick)

NonStop SQL Up to version 3.x (tick)

Ingres / Actian Up to version 12.x (tick)

Transactions

Transaction support is derived from metamodel concepts used to build CAST Imaging Blueprint and structural transaction flows. Entry Points start transactions; Exit Points include both output/boundary concepts and Data Entities manipulated by transactions.

Role Support Breakdown
Entry Point No direct concept type details
Exit Point
  • Run Service
  • Database Function
  • Procedure
Data Entity with Accurate FP
  • Table
  • View
Data Entities
  • SQL Table - Unresolved

Data version: 3.8.3-funcrel

ISO 5055 Structural Rules

Quality support is based on ISO 5055 structural rules available for the selected extension version.

Reliability Maintainability Security Performance Efficiency

Data version: 3.8.3-funcrel

What results can you expect?

Objects

See detail about how the system objects are determined here : SQL Analyzer - System Object.

Type Name Description
Event Event Created from CREATE EVENT statements.
System Event System Event Represents an event identified as a system event.
SQL Script DML Script File Created for files containing DML statements such as INSERT, LOAD, UPDATE, DELETE, and SELECT. Candidates containing more than 80% INSERT statements are considered data exports and are not analyzed. Files mixing DML and DDL statements can be considered both DML and DDL scripts.
Macro Macro Created from CREATE MACRO statements.
System Macro System Macro Represents a macro identified as a system macro.
Package Package Created from CREATE PACKAGE and CREATE PACKAGE BODY statements.
System Package System Package Represents a package identified as a system package.
SQL Call to C/C++ Function SQL Call to C/C++ Function A SQL Call to a C/C++ Function that will be executed when the Procedure / Function is called. Added for a Procedure / Function implemented in C/C++.
SQL Call to Java Method SQL Call to Java Method A SQL Call to a Java Method that will be executed when the Procedure / Function is called. Added for a Procedure / Function implemented in Java.
SQL Call to Program SQL Call to Program A SQL Call to a Cobol/RPG400/RPG300/CL400/Assembler/Rexx program or a PLI/PLC MainProcedure that will be executed when the Procedure / Function is called. Added for a Procedure / Function implemented in Cobol (language COBOL/COBOLLE), RPG IV (language RPGLE), RPG III (language RPG), CL IV (language CL), PL/I (language PLI), Assembler (language ASSEMBLE).
System Table Column System Table Column Represents a column belonging to a system table or system view.
Table Column Table Column Created for columns detected in CREATE TABLE statements. For CREATE VIEW statements, only aliases assigned to selected expressions are considered column names.
Function Function Created from CREATE FUNCTION statements. This type also represents functions declared inside packages.
Method Method Represents a method declared by an SQL object type.
System Function System Function Represents a standalone or packaged function identified as a system function.
System Method System Method Represents a method belonging to a system SQL object type.
Unresolved Function Unresolved Object Created when a procedure-like or function-like object accessed through a database link cannot be resolved in the analysis results.
Index Index Created from CREATE INDEX statements.
System Index System Index Represents an index belonging to a system table.
Foreign Key Foreign Key Created from foreign-key definitions in CREATE TABLE or ALTER TABLE statements.
System Foreign Key System Foreign Key Represents a foreign-key constraint belonging to a system table.
System Unique Constraint System Unique Constraint Represents a unique or primary-key constraint belonging to a system table.
Unique Constraint Unique Constraint Created from CREATE UNIQUE INDEX or primary-key statements. Tables are marked as having a primary key when appropriate. Keys in .pf and .pf38 files are created for the Db2 for i variant, using the file name prefixed with PK_.
Missing Procedure SQL Missing Procedure A procedure or a function called in a View / Trigger / Event / Macro / Procedure / Function / Method / DML Script file missing from the DDL file.
Procedure Procedure Created from CREATE PROCEDURE and REPLACE PROCEDURE statements. This type also represents procedures declared inside packages.
System Procedure System Procedure Represents a standalone or packaged procedure identified as a system procedure.
Missing Schema SQL Missing Schema Created as the parent of a missing table or missing procedure when its schema cannot be resolved.
Schema Schema Created for schemas detected in all supported RDBMS. See SQL Analyzer - How object identity is determined for details about how the schema is determined.
System Schema System Schema Represents a schema identified as a system schema in a supported RDBMS. It can contain system tables, views, and other system objects.
Unresolved Schema Unresolved Schema Created as the parent of unresolved tables and unresolved procedure-like objects accessed through a database link. See SQL Analyzer - How object identity is determined for an example.
Database Database Created for MS SQL Server, ASE Sybase, IBM Db2, CockroachDB, and NonStop SQL. See SQL Analyzer - How object identity is determined for details about how the database is determined.
System Database System Database Represents a database identified as a system database for MS SQL Server, ASE Sybase, IBM Db2, CockroachDB, or NonStop SQL.
Missing Table SQL Missing Table Created when a table or view referenced by a view, trigger, event, macro, procedure, function, method, or DML script is missing from the analyzed DDL files.
Synonym Synonym Created from CREATE SYNONYM, CREATE ALIAS, CREATE SQLMP ALIAS, and CREATE NICKNAME statements.
System Table System Table Represents a table identified as a system table in the analyzed database.
Table Table Created from CREATE TABLE statements. Records in .pf and .pf38 files are also created as tables for the Db2 for i variant, using the file name as the table name.
Unresolved Table Unresolved Table Created when a table-like object accessed through a database link cannot be resolved in the analysis results.
System Trigger System Trigger Represents a trigger identified as a system trigger.
Trigger Trigger Created from CREATE TRIGGER and CREATE RULE statements.
System View System View Represents a view identified as a system view in the analyzed database.
View View Created from CREATE VIEW and REPLACE VIEW statements. Records in .lf and .lf38 files are also created as views for the Db2 for i variant, using the file name as the view name.
Database Link Database Link Created from CREATE DATABASE LINK statements.
System Database Link System Database Link Represents a database link identified as a system database link.
System Synonym System Synonym Represents a synonym, alias, or nickname identified as a system object.
System Type System Type Represents a user-defined type identified as a system type.
Type Type Created from CREATE TYPE and CREATE TYPE BODY statements.
sourceFile sourceFile Logical file created for each analyzed source file. It includes a Vendor property identifying the SQL variant used for analysis. See SQL file Vendor - This file is analyzed against XXX variant.

Table deletion and renaming

DROP TABLE syntax is supported for table objects within the same file. When creating a table through CREATE TABLE tableName (colName int, …) followed by a DROP TABLE tableName, the table will not be recorded and thus will not be displayed in CAST Enlighten. When a table is dropped, its indexes are dropped as well. Similarly, if a table is renamed with a RENAME TABLE statement (or ALTER TABLE RENAME TO as in SQLite and PostgreSQL), this change will be reflected in CAST Enlighten. Presently we consider case-insensitive names, i.e., objects named tableName, TABLEname are considered to be the same object.

Links are created for transaction and function point needs.

First table is for SQL objects created in SQL files and we call them server side links. The second is for queries from the different client languages and we call them client server links.

Link Type Caller type Callee type Details / Comments
useSelect, useUpdate, useDelete, useInsert Procedure
Function
Macro
Event
View
DML Script File
Table
View
Synonym
SQL Missing Table
callLink Procedure
Function
Event
Macro
View
DML Script File
Procedure
Function
Synonym
SQL Missing Procedure
callLink Method’s Type Method’s Type When an PL/SQL object’s method is called indirectly, via a variable.
callLink Procedure, Function SQL Call to Program
callLink Procedure, Function SQL Call to Java Method
callLink Procedure, Function SQL Call to C/C++ Function
callLink Trigger Procedure
Function
when table is INSERTED, UPDATED, DELETED in a Procedure, Function we add a call link between the Procedure, Function and the Trigger.
relyonLink Index Table
relyonLink Index Index’s Column
relyonLink Synonym Table
View
Function
Procedure
Package
relyonLink Type’s Method / Function / Procedure Type
Table
When parameter/variable datatypes are PL/SQL Type/Table Columns.
referLink Table, Table Column Table
Table Column
From a Table/Table Column to a Table/Table Column referenced in a Foreign Key.
referUpdate Table Table From a Table to the Table referenced in a Column referenced in a Foreign Key.
referDelete Table Table From a Table to the Table referenced in a Column referenced in a Foreign Key:



callLink DML Script File, SQL Query Trigger Call the Trigger when the tables are inserted/updated/deleted:



inheritExtendLink sub Type super Type For PL/SQL Types.
inheritOverrideLink Method Type Method Type From a PL/SQL Method’s Type which override a super Type’s Method.
useLink Type Type For PL/SQL tables, example:
CREATE OR REPLACE TYPE "CNCUBLIST_2" is table of "HIS_TEST_A";

monitorInsert, monitorUpdate, monitorDelete Trigger Table
View
Links Created by Universal Linker
Link Type Caller type Callee type
callLink SQL Call to Program A Cobol/RPG400/RPG300/CL400/Assembler/Rexx program or a PLI/PLC MainProcedure
callLink SQL Call to Java Method A Java Method
callLink SQL Call to C/C++ Function A C/C++ Function

SQL Analyzer is responsible to create the following client server links for the embedded SQL supported by Analyzers and extensions, that is through SQL Query and Entity / Entity Operations intermediate objects. This is the case of JDBC, JPA / Hibernate, EF, Ado.net, Dapper, Embeded SQL in COBOL, Pro*C, Python, Shell, NodeJS, Oracle Forms and Reports, etc.

Link Type Caller type Callee type Details / Comments
useSelect, useUpdate, useDelete, useInsert SQL Query, Java Property Mapping, Entity Operation Table
View
Synonym
SQL Missing Table
SQL Query is a Client SQL Query, having the icon .
A Java Property Mapping is property similar to a SQL statement.
Java Property object icon is .
Entity Operations are client objects like JPA Entity Operation, NodeJS Entity Operation, etc.
If a table is selected in the Cobol / RPG SQL Query DECLARE C1 CURSOR we consider it is selected in the Cobol SQL Query FETCH C1.
callLink SQL Query, Java Property Mapping Procedure
Function
Macro
Synonym
SQL Missing Procedure
callLink Trigger SQL Query, Java Property Mapping When table is INSERTED, UPDATED, DELETED in a SQL Query, Java Property Mapping we add a call link between the SQL Query, Java Property Mapping and the Trigger.
useSelect, useUpdate, useDelete, useInsert IMS SQL Query IMS DB Segment
monitorInsert, monitorUpdate, monitorDelete Oracle Forms Trigger Table
View
ddlCreateLink SQL Query Table
SQL Embedded Table
For CREATE TABLE statements
ddlAlterLink SQL Query Table
SQL Embedded Table
For ALTER TABLE statements
ddlReplaceLink SQL Query Table
SQL Embedded Table
For REPLACE TABLE statements
ddlDropLink SQL Query Table
SQL Embedded Table
For DROP TABLE statements
ddlLink SQL Query Table
SQL Embedded Table
For DECLARE TABLE and RENAME TABLE statements

Quality rules

You can find a full list of rules delivered with this extension here:

Cyclomatic Complexity external link is fixed for IF/ELSE IF statements, but AND and OR remain unsupported in AIP 8.3.x.

Removes SQL Analyzer contribution from rule 7346 (Avoid redundant indexes), now covered by dedicated rule 1101118 (Avoid redundant indexes (SQL)). Rule 7346 remains active for other technologies.

Client Side Support

This section lists the metamodel object types that benefit from client-side support:

  • a series of quality rules operating on the SQL statements extracted from the embedded SQL code : EXEC SQL blocks, Native SQL queries. This excludes pure ORM accesses where the full SQL statement is determined at runtime, thus not accessible to the analysis engine.
  • Data Column Access enablement, for links and sensitive data feature.

The table is generated from all published metamodel objects assigned to the data-query (SQL Query) concept.

85 object types
Object type Technology / Language Extension
Net.Data SQL Function CAST_HTML5_NETDATA_SQL_Function
- HTML5/Javascript Analyzer
SQL Named Stored Procedure Query CAST_SQL_NamedStoredProcedureQuery
- JEE Analyzer
Dotnet Analyzer SQL Query CAST_DotNet_Analyzer_SQLQuery
.NET .NET Analyzer
Dapper SQL Query CAST_DotNet_Dapper_SQLQuery
.NET Dapper Analyzer
MS Enterprise Library SQL Query CAST_DotNet_EntLib_SQL_Query
.NET MS Enterprise Library Analyzer
Dotnet Ado Query CAST_Dotnet_ADO_SqlQuery
ADO.NET ADO.NET Analyzer
DotNet ADO Unknown Query CAST_Dotnet_ADO_SqlQuery_Unknown
ADO.NET ADO.NET Analyzer
DotNet Unknown ADO Query CAST_DotNet_Unknown_ADO_SqlQuery
ADO.NET ADO.NET Analyzer
DotNet ADODB SQL Query CAST_DotNet_ADODB_SQL_Query
ADODB ADODB Analyzer
DotNet ADODB Unknown SQL Query CAST_DotNet_Unknown_ADODB_SQLQuery
ADODB ADODB Analyzer
Android SQL Query CAST_Android_SQL_Query
Android Mobile Android Analyzer
Kotlin SQL Query CAST_Kotlin_SQL_Query
Android Mobile Kotlin Analyzer
SQL Named Query CAST_SQL_NamedQuery
ANSI SQL JEE Analyzer
Apache Camel Database Query Object CAST_ApacheCamel_DatabaseQuery
Apache Camel Apache Camel Analyzer
Cassandra Java CQL Query CAST_Java_Cassandra_CQLQuery
Apache Cassandra for Java Apache Cassandra Analyzer Java
Apache Commons DbUtils Query CAST_Java_CommonsDbUtils_SqlQuery
Apache Commons Apache Commons DbUtils Analyzer
Apache Unknown Commons DbUtils Query CAST_Java_Unknown_CommonsDbUtils_SqlQuery
Apache Commons Apache Commons DbUtils Analyzer
Spark JDBC SQL Query CAST_Java_Spark_JDBC_SQLQuery
Apache Spark for Java Apache Spark JDBC Analyzer
Spark JDBC Unknown SQL Query CAST_Java_Unknown_Spark_JDBC_SQLQuery
Apache Spark for Java Apache Spark JDBC Analyzer
MS ApplicationBlocks Data SQL Query CAST_DotNet_MSAppBlocks_SQL_Query
ApplicationBlocks Data MS ApplicationBlocks Data Analyzer
MS ApplicationBlocks Data Unknown SQL Query CAST_DotNet_Unknown_MSAppBlocks_SQLQuery
ApplicationBlocks Data MS ApplicationBlocks Data Analyzer
Easytrieve SQL Query CAST_Easy_SQLQuery
Broadcom CA-Easytrieve Plus Easytrieve Analyzer
SQL Query CAST_C_SQLQuery
CFamily C/C++ Analyzer
HTML5 SQL Query CAST_HTML5_SQL_Query
Classic ASP HTML5/Javascript Analyzer
Dapper Unknown SQL Query CAST_DotNet_Unknown_Dapper_SQLQuery
Dapper Dapper Analyzer
DevExpress XPO SQL Query CAST_DevExpress_XPO_SQL_Query
DevExpress DevExpress XPO Analyzer
DevExpress XPO Unknown SQL Query CAST_DevExpress_XPO_Unknown_SQL_Query
DevExpress DevExpress XPO Analyzer
Birt SQL Query CAST_Birt_Query
Eclipse BIRT Business Intelligence and Reporting Tools Analyzer
EF SQL Query CAST_DotNet_Entity_SQLQuery
Entity Framework - EF6 .NET Entity Analyzer
EF Unknown SQL Query CAST_DotNet_Unknown_Entity_SQLQuery
Entity Framework - EF6 .NET Entity Analyzer
Hibernate HQL Named Query HIB_HQL_NAMED_QUERY
Hibernate JEE Analyzer
Hibernate SQL Named Query HIB_SQL_NAMED_QUERY
Hibernate JEE Analyzer
Cobol SQL Query CAST_Cobol_SQLQuery
IBM Cobol Mainframe Analyzer
z/OS Assembler SQL Query AssemblerZOS_SQLQuery
IBM High Level Assembler z/OS Assembler Analyzer
CL Call to Sql File CL400SqlFileQuery
IBM i IBM RPG Analyzers
CL EXEC SQL CL400SQLStructure
IBM i IBM RPG Analyzers
RPG III EXEC SQL RPG300SQLStructure
IBM i RPG IBM RPG Analyzers
RPG IV EXEC SQL RPG400SQLStructure
IBM i RPG IBM RPG Analyzers
IMS SQL Query CAST_IMS_SQLQuery
IBM IMS DB Mainframe Analyzer
PLC SQL Query PLCSqlQuery
IBM PLI IBM PL/I Analyzer
PLI SQL Query PLISqlQuery
IBM PLI IBM PL/I Analyzer
JCL SQL Query CAST_JCL_SQLQuery
IBM z/OS JCL Mainframe Analyzer
JPQL Query CAST_Java_JPA_JPQLQuery
Java Java Persistences Analyzer
Batch JDBC Query CAST_Batch_JDBC_Query
Java Batch Batch Analyzer
Batch JDBC Unknown Query CAST_Unknown_Batch_JDBC_Query
Java Batch Batch Analyzer
Batch JPQL Query CAST_Batch_JPA_SQLQuery
Java Batch Batch Analyzer
Batch JPQL Unknown Query CAST_Unknown_Batch_JPA_SQLQuery
Java Batch Batch Analyzer
Batch SQL Query CAST_Batch_SQL_Query
Java Batch Batch Analyzer
Batch SQL Unknown Query CAST_Unknown_Batch_SQL_Query
Java Batch Batch Analyzer
JDBC SQL Query CAST_JAVA_JDBC_SQLQuery
JDBC JDBC Analyzer
JDBC Unknown SQL Query CAST_Java_Unknown_JDBC_SQLQuery
JDBC JDBC Analyzer
JDBI SQL Query CAST_JAVA_JDBI_SQLQuery
Jdbi JDBI Analyzer
JDBI Unknown SQL Query CAST_JAVA_Unknown_JDBI_SQLQuery
Jdbi JDBI Analyzer
jOOQ SQL Query CAST_JAVA_JOOQ_SQLQuery
jOOQ jOOQ Analyzer
jOOQ Unknown SQL Query CAST_Java_Unknown_JOOQ_SQLQuery
jOOQ jOOQ Analyzer
JPA SQL Query CAST_Java_JPA_SQLQuery
JPA Java Persistences Analyzer
JPA Unknown SQL Query CAST_Java_Unknown_JPA_SQLQuery
JPA Java Persistences Analyzer
JPA Named Native Query JPA_NAMED_NATIVE_QUERY
JPA JEE Analyzer
JPA Named Query JPA_NAMED_QUERY
JPA JEE Analyzer
MS Enterprise Library Unknown SQL Query CAST_DotNet_Unknown_EntLib_SQLQuery
MS Enterprise Library MS Enterprise Library Analyzer
DotNet MyBatis SQL Query CAST_MYBATIS_DOTNET_SQLNAMEDQUERY
MyBatis for .NET MyBatis/iBatis Analyzer
DotNet MyBatis Unknown SQL Query CAST_DotNet_MYBATIS_Unknown_SQLQuery
MyBatis for .NET MyBatis/iBatis Analyzer
Java MyBatis SQL Query CAST_JAVA_MYBATIS_SQLQuery
MyBatis for Java MyBatis/iBatis Analyzer
Java MyBatis Unknown SQL Query CAST_JAVA_Unknown_MYBATIS_SQLQuery
MyBatis for Java MyBatis/iBatis Analyzer
NHibernate HQL Query CAST_DotNet_NHibernate_HQLQuery
NHibernate .NET NHibernate Analyzer
NHibernate SQL Query CAST_DotNet_NHibernate_SQLQuery
NHibernate .NET NHibernate Analyzer
NHibernate Unknown SQL Query CAST_DotNet_Unknown_NHibernate_SQLQuery
NHibernate .NET NHibernate Analyzer
NodeJS SQL Query CAST_NodeJS_SQL_NamedQuery
Node.js Node.js Analyzer
NPoco SQLQuery CAST_DotNet_NPoco_SQLQuery
NPoco PetaPoco .NET Analyzer
NPoco Unknown SQLQuery CAST_DotNet_NPoco_Unknown_SQLQuery
NPoco PetaPoco .NET Analyzer
Oracle Report SQL Query CAST_FormsScript_Query
Oracle Forms Oracle Forms and Reports Analyzer
ORMLite SQL Query CAST_Java_ORMLite_SQLQuery
OrmLite ORMLite Analyzer
ORMLite Unknown SQL Query CAST_Java_Unknown_ORMLite_SQLQuery
OrmLite ORMLite Analyzer
Python File Query CAST_Python_File_Query
Python Python Analyzer
Python ORM Mapping CAST_Python_ORM_Mapping
Python Python Analyzer
Python Query CAST_Python_Query
Python Python Analyzer
Spring JDBC Query CAST_SpringJDBC_Query
Spring Spring Data/JDBCs Analyzer
Spring Data JPQL Query CAST_SpringData_JPA_SQLQuery
Spring Data Spring Data/JDBCs Analyzer
Spring Data Query CAST_SpringData_Query
Spring Data Spring Data/JDBCs Analyzer
Spring Data JPQL Unknown Query CAST_Unknown_SpringData_JPA_SQLQuery
Spring Data JPA Spring Data/JDBCs Analyzer
Spring Data Unknown Query CAST_Unknown_SpringData_Query
Spring Data JPA Spring Data/JDBCs Analyzer
Spring JDBC Unknown Query CAST_Unknown_SpringJDBC_Query
Spring JDBC Spring Data/JDBCs Analyzer
SubSonic SQL Query CAST_DotNet_SubSonic_SQLQuery
SubSonic SubSonic .NET Analyzer
SubSonic Unknown SQL Query CAST_DotNet_Unknown_SubSonic_SQLQuery
SubSonic SubSonic .NET Analyzer
TypeScript SQL Query CAST_TS_Query
TypeScript Typescript and frameworks Analyzer

The quality rules are calculated on the client side on the SQL Query objects, even when there is no SQL Analyzer database / schema. From a technical point of view, the following Embedded SQL Query mechanisms are supported:

Embedded SQL Queries Details / Comments
SQL Queries CAST_SQL_MetricableQuery.sqlQuery on objects which inherit from the category CAST_SQL_MetricableQuery.
SQL Query is a Client SQL Query, having the icon .
Java Property Mapping CAST_JEE_MappingProperties.mapValue on Java Property Mapping objects. A Java Property Mapping objet is a Java object having the icon .
Inference Engine Queries physicalLink.inferenceEngineRequests on Inference Engine links

Quality rules applied to the SQL queries:

Name
Calculated only when we have SQL Analyzer database / schema
Never use SQL queries with a cartesian product (SQL) (1101000)
Never use SQL queries with a cartesian product on XXL Tables (SQL) (1101002) (tick)
Avoid non-indexed SQL queries (1101004) (tick)
Avoid non-indexed XXL SQL queries (1101006) (tick)
Avoid non-SARGable queries (1101008)
Avoid NATURAL JOIN queries (1101010)
Specify column names instead of column numbers in ORDER BY clauses (1101012)
Avoid queries using old style join convention instead of ANSI-Standard joins (SQL) (1101014)
Avoid using the GROUP BY clause (1101018)
Always define column names when inserting values (1101026)
Use MINUS or EXCEPT operator instead of NOT EXISTS and NOT IN subqueries (1101028)

Avoid EXISTS and NOT EXISTS independent clauses (SQL) (1101032)


Avoid using DISTINCT in SQL SELECT statements (1101034)


Use ANSI standard operators in SQL WHERE clauses (EMBEDDED SQL) (1101036)


Avoid OR conditions testing equality on the same identifier in SQL WHERE clauses (1101038)


Avoid mixing ANSI and non-ANSI JOIN syntax in the same query (1101058)
Avoid using LIKE conditions starting with a wildcard character (1101060)
Avoid improperly written  triangular joins with XXL tables (1101066) (tick)
Avoid explicit comparison with NULL (1101070)
Avoid not aliased Tables (1101072)
Avoid Tables aliases ending with a numeric suffix (1101074)
Avoid unqualified column references (1101076) (tick)
Avoid using LIKE conditions without wildcards (1101102)
Avoid Cobol SQL Cursors without FOR READ ONLY or FOR FETCH ONLY or FOR UPDATE clauses (EMBEDDED SQL) (1101108)
Avoid LOCK TABLE statements in SQL code for COBOL Programs (1101112)

Special note about XXL/XXS support

See Working with XXL or XXS tables.

Special notes about Quality Rules on client side

Some Quality Rules are calculated on SQL queries on the client-side with some limitations:

  • Quality Rules will be enabled on client-side code only if the server-side code has been analyzed with SQL Analyzer extension.
  • For Java client-side code, SQL statements used in parameters of methods including a SQL parametrization rule are analyzed.

Example of call to a parametrized method

class Foo
{
   final static String TABLE_NAME = "Person";

    void method()
    {
        String query = "select * from " + this.TABLE_NAME;
        java.sql.Statement.execute(query );
    }
}
  • But ‘queries’ visible in the DLM (that need reviewing) are not analyzed:

Example of a query visible in the DLM

class Foo
{
    // not passed to an execute something
    private final static String text = "select name from Person";
}
  • Explicit queries used in an ORM context are analyzed (or not) based on if they are visible in Enlighten

  • The following types of queries are analyzed:

    • COBOL EXEC SQL
    • RPG/CL
    • Pro*C
  • SQL queries found in Python / Shell code are analyzed

  • SQL queries found in .properties (Java Property Mapping objects) are analyzed

Special note about redundant Quality Rules

Please see SQL Analyzer - Redundant Quality Rules not included in the SQL Analyzer.

LOC - Line of Code Counting in SQL Analyzer

LOC (Line of Code) values reported by the CAST Dashboards are specifically and only for files that are classed by CAST as “sourceFiles” (File which contains source code), with the ID 1000007. LOC values are not reported for objects.

Errors and warning

Please see Log messages for the full list of analysis errors and warnings.

Known limitations and issues

Installation

If you encounter the following error in CAST Server Manager while installing the SQL Analyzer extension, please perform the workaround described here and then attempt the installation again. This error may occur if you have installed a very old and unsupported custom Universal Analyzer language pack that used the same metamodel type names as used in the official SQL Analyzer extension.

SQL Analyzer is incompatible with the schema metamodel. It is generally due to an extension that has changed its ids.

Analysis

  • All name resolution is considered as case insensitive: this may produce erroneous links on a case insensitive platform ‘playing with case’: two different tables with the same case insensitive name will be both called
  • Procedure resolution handles overriding when the number of parameters are matched or number and optionals are matched. Otherwise, when calling an overridden procedure, all overrides will be called. Below are some examples here is a single call Link, between the second func1 and func2:

Match number of parameters

CREATE FUNCTION func1() RETURNS integer AS
begin
    DELETE FROM table1 WHERE ID in (SELECT ID FROM table2);
end;

CREATE FUNCTION func1(mode integer) RETURNS integer AS
begin
    DELETE FROM table1 WHERE ID (SELECT ID FROM table2);
end;

CREATE FUNCTION func2(mode integer) RETURNS integer AS
begin
    select func1 (mode); 
end;

Match number of parameters and how many are optionals

CREATE FUNCTION func1(i_mode integer) RETURNS integer AS
begin
    DELETE FROM table1 WHERE ID in (SELECT ID FROM table2);
end;

CREATE FUNCTION func1(mode integer := 1) RETURNS integer AS
begin
    DELETE FROM table1 WHERE ID in (SELECT ID FROM table2);
end;

CREATE FUNCTION func2(mode integer) RETURNS integer AS
begin
    select func1 (); 
end;
  • Dynamic SQL statements are resolved when:
    • the SQL statement is readable, even for sliced statements.

    • TABLE1, TABLE2, TABLE3 and TABLE4 are visibles and useSelect link were be added

CREATE PROCEDURE test
AS
L_QryStr varchar2(4000);
begin
L_QryStr := 'select S.COL1, P.COL2, P.COL3, P.COL4, P.COL5, ' ||
' P.COL6, B.COL7, R.COL8, B.COL9, B.COL10' ||
' from TABLE1 S, TABLE2 P, TABLE3 B, ' ||
' ( select distinct R.COL1, R.COL2 ' ||
' from TABLE4 R ' ||
' where R.COL3 = 99999 ';
EXECUTE IMMEDIATE L_QryStr;
end;
/
    • test_table is visible and useDelete link is added:
CREATE PROCEDURE test
AS
begin
EXECUTE IMMEDIATE 'truncate table test_table'; 
end;
/
    • test_table is visible and useDelete link is added:
CREATE PROCEDURE test
AS
L_QryStr varchar2(4000);
begin
    L_QryStr := 'truncate table ';
    L_QryStr := L_QryStr || ' test_table ';
    EXECUTE IMMEDIATE L_QryStr; 
end;
/
    • table name is valued via a variable which could be resolved.
    • emp table is visible and useSelect link will be added
CREATE PROCEDURE test
AS
emp_rec  emp%ROWTYPE;
sql_stmt VARCHAR2(200);
begin
    sql_stmt := 'SELECT * FROM || emp_rec.T1 ||  WHERE job = 1';
    EXECUTE IMMEDIATE sql_stmt;
end;
/
    • emp table is visible and useSelect link will be added
CREATE OR REPLACE package body test_package as
 
 type T_1 is table of varchar2(22);
 emp_rec  emp%ROWTYPE;

 PROCEDURE test
is
sql_stmt VARCHAR2(2000);
emp_tab VARCHAR2(200);
begin
    emp_tab := emp_rec;
    sql_stmt := 'SELECT * FROM || emp_tab ||  WHERE job = :j';
    EXECUTE IMMEDIATE sql_stmt;
end test;
 
end;
/
    • OPEN-FOR-USING : emp table and test procedure are linked by a use SELECT link
create table emp (col1 int);
/
CREATE OR REPLACE type body test_body as

 type t_emp is table of t_table index by varchar2(22);
 emp_rec  emp%ROWTYPE;

 member PROCEDURE test(o_cursor OUT my_cursor)
IS
BEGIN
   OPEN    o_cursor FOR
   'SELECT  rule_id,
           expression_id,
           parent_expression_id,
           operator
   FROM    emp
   ORDER   BY rule_id, expression_id';
END test;

end;
/
create table emp (col1 int);
/
CREATE OR REPLACE type body test_body as

 type t_emp is table of t_table index by varchar2(22);
 emp_rec  emp%ROWTYPE;

 member PROCEDURE test(o_cursor OUT my_cursor)
IS
L_SQL varchar(20000) := '';
BEGIN
    L_SQL := 'SELECT  rule_id,
           expression_id,
           parent_expression_id,
           operator
   FROM    emp
   ORDER   BY rule_id, expression_id';
   
   OPEN o_cursor FOR L_SQL;
END test;

end;
/
  • ALTER TABLE … ADD …, ALTER TABLE/VIEW … SET SCHEMA …, ALTER DATABASE … CONVERT TO SCHEMA WITH PARENT … syntaxes are supported. All other syntaxes, such as ALTER TABLE … DELETE .. or ALTER TABLE … DROP … or ALTER TABLE … MODIFY … etc. are not supported.

  • Moving a table from one database/scheme to another is not supported through RENAME TABLE schema1.tableName1 TO schema2.tableName2.   

  • Sequences are not taken into account and that is not a limitation but a choice because they have no effect on transactions nor Quality Rules

  • Oracle synonyms on packages are not taken into account.

  • For the QR 1101012 Specify column names instead of column numbers in ORDER BY clauses, the case when a function that returns a number or a numeric variable is used in order by is not reported to violate the rule.

Transitioning from from the CAST AIP Db2 Analyzer to the SQL Analyzer extension

If you have been actively analyzing Db2 (z/OS or LUW) with the Db2 Analyzer (provided out-of-the-box in CAST AIP) you can transition to using the SQL Analyzer extension to analyze your Db2 source code. The process of transitioning is described in SQL Analyzer - To do transition from the CAST AIP Db2 Analyzer to the SQL Analyzer extension.

Reversed links

When transitioning from the Db2 Analyzer to the SQL Analyzer, links between Tables and Indexes, Foreign Keys, Primary Keys and Unique Keys will appear to be reversed when comparing the analysis results of the Db2 Analyzer and the SQL Analyzer. This is because the representation of links in the SQL Analyzer uses a different method (which is identical for all supported RDBMS) to the Db2 Analyzer.

Transitioning from the CAST AIP Oracle Analyzer to the SQL Analyzer extension

If you have been actively analyzing Oracle with the Oracle Analyzer (provided out-of-the-box in CAST AIP) you can transition to using the SQL Analyzer extension to analyze your Oracle source code. The process of transitioning is described in SQL Analyzer - To do transition from the CAST AIP Oracle Analyzer to the SQL Analyzer extension.

Analyzing the same code will generate differences in results across object types, object links and structural rules. If you do decide to move to the SQL Analyzer extension, see SQL Analyzer - Mapping between SQL analyzers for more information about what you can expect.

(warning) Important! Don’t change analyzed sources, keep analyzing src files. Only GUIDs are changed during transitions, checksums are recalculated, and that will impact transactions. 

Oracle Forms and Reports particular case

  • If you have already analyzed Oracle Forms and Reports code that is linked to PL/SQL code analyzed with the SQL analyzer embedded in CAST AIP, CAST recommends that you continue using the SQL analyzer embedded in CAST AIP.

Transitioning from the CAST AIP SQL Server Analyzer to the SQL Analyzer extension

If you have been actively analyzing MS SQL Server with the MS SQL Server Analyzer (provided out-of-the-box in CAST AIP) you can transition to using the SQL Analyzer extension to analyze your SQL Server source code. The process of transitioning is described in How to do transition from the CAST MS SQL Server Analyzer to the SQL Analyzer extension.

Analyzing the same code will generate differences in results across object types, object links and structural rules. If you do decide to move to the SQL Analyzer extension, see SQL Analyzer - Mapping between SQL analyzers for more information about what you can expect.

(warning) Important! Don’t change analyzed sources, keep analyzing src files. Only GUIDs are changed during transitions, checksums are recalculated, and that will impact transactions. 

Transitioning from the CAST AIP ASE Sybase Analyzer to the SQL Analyzer extension

If you have been actively analyzing ASE Sybase with the ASE Sybase Analyzer (provided out-of-the-box in CAST AIP) you can transition to using the SQL Analyzer extension to analyze your ASE Sybase source code. The process of transitioning is described in SQL Analyzer - To do transition from the CAST AIP ASE Sybase Analyzer to the SQL Analyzer extension.

Analyzing the same code will generate differences in results across object types, object links and structural rules. If you do decide to move to the SQL Analyzer extension, see SQL Analyzer - Mapping between SQL analyzers for more information about what you can expect.

(warning) Important! Don’t change analyzed sources, keep analyzing src files. Only GUIDs are changed during transitions, checksums are recalculated, and that will impact transactions.