SqlGenerator

Overview

The SqlGenerator class provides methods to generate SQL SELECT statements and command execution SQL statements based on the information about data table name, it's fields, etc.

This class is used internally by the BusinessProcessor and ServiceSchema classes to generate appropriate SQL statements.

Location


Constants


OldParamPrefix

Gets prefix that is used to distinguish SQL statement parameters that correspond to old values provided in the DeltaChange object.

Value of this constant equals to OLD_.

 

const OldParamPrefix: String = "OLD_";

 

const String OldParamPrefix = "OLD_"

 

Dim OldParamPrefix As String = "OLD_"

Class Methods


GenerateCommandSQL

Composes command SQL statement based on information about database connection being used, Schema data table, type of change update operation (INSERT, UPDATE or DELETE), DeltaChange object, UpdateMode value and column mapping collection.

 

class method GenerateCommandSQL(connection: IAbstractConnection; tableSchema: SchemaDataTable; changeType: ChangeType; change: DeltaChange; updateMode: UpdateMode; tableMapping: SchemaColumnMappingCollection; out parameters: SchemaParameterCollection): String

 

static String GenerateCommandSQL(IAbstractConnection connection, SchemaDataTable tableSchema, ChangeType changeType, DeltaChange change, UpdateMode updateMode, SchemaColumnMappingCollection tableMapping, out SchemaParameterCollection parameters)

 

Shared Function GenerateCommandSQL(connection As IAbstractConnection, tableSchema As SchemaDataTable, changeType As ChangeType, change As DeltaChange, updateMode As UpdateMode, tableMapping As SchemaColumnMappingCollection, <OutAttribute> ByRef parameters As SchemaParameterCollection) As String

Parameters:

  • connection: Active database connection
  • tableSchema: Target Schema table
  • changeType: Change type. See the ChangeType enumeration description for possible values
  • change: DeltaChange instance. Contains changed table fields values
  • updateMode: Denotes fields that should be included into the WHERE clause of the generated SQL statement. See the UpdateMode enumeration description for possible values
  • tableMapping: Mapping between database table fields and Schema table fields
  • parameters: After execution of the method this argument will contain collection of parameters needed to be provided to execute the generated SQL statement

GenerateSelectSQL

Composes SELECT SQL statement based on information about database connection being used, Schema data table, FieldSelection value and other options.

 

class method GenerateSelectSQL(connection: IAbstractConnection; tableSchema: SchemaDataTable; fields: array of String; fieldSelection: FieldSelection; includePkWhere: Boolean; out parameters: SchemaParameterCollection): String

 

static String GenerateSelectSQL(IAbstractConnection connection, SchemaDataTable tableSchema, String[] fields, FieldSelection fieldSelection, Boolean includePkWhere, out SchemaParameterCollection parameters)

 

Shared Function GenerateSelectSQL(connection As IAbstractConnection, tableSchema As SchemaDataTable, fields As String(), fieldSelection As FieldSelection, includePkWhere As Boolean, <OutAttribute> ByRef parameters As SchemaParameterCollection) As String

Parameters:

  • connection: Active database connection
  • tableSchema: Target Schema table
  • fields: List of filed names that should be included into the generated SELECT statement
  • fieldSelection: FieldSelection value that denotes which subset of the Schema should be included into the generated SELECT statement
  • includePkWhere: Flag indicating whether primary key should be included into the WHERE clause of the generated SQL statement
  • parameters: After execution of the method this argument will contain collection of parameters needed to be provided to execute the generated SQL statement