Show / Hide Table of Contents

Class OracleCommon

This class contains the common SQL-syntax for the Oracle DB.

Inheritance
object
Dialect
OracleCommon
Oracle12
Inherited Members
Dialect._tables
Dialect._tablesInJoin
Dialect._returnDBFields
Dialect._dbSchemaTable
Dialect._soSchemaTable
Dialect._returnArguments
Dialect._usedAliases
Dialect._filterCallbacks
Dialect._cmd
Dialect._stringFieldsInOrderByWithDistinct
Dialect.ShouldRowBeSkipped(IDataReader)
Dialect.IsTableReferencedInSelect(SoTable)
Dialect.GetUpdatedSchemaTable(DataTable)
Dialect.GenerateCaseInsensitivity(FieldInfo, Parameter, string)
Dialect.GetOriginAsComment(SqlCommand)
Dialect.HandleDateAndTimeWrapping(string, FieldDataType)
Dialect.GetFieldDbDataType(int)
Dialect.GetIndexOfField(Argument)
Dialect.GetFieldInfoFromIndex(int)
Dialect.CheckForAlias()
Dialect.InvokeToSql(params object[])
Dialect.IsAnyArgumentString(params Argument[])
Dialect.ToSqlUpperIfNeeded(Argument)
Dialect.ToSqlFrom(SqlType)
Dialect.ToSqlField(FieldInfoCollection)
Dialect.ToSqlField(ArgumentCollection)
Dialect.ToSqlField(ReturnFieldsCollection)
Dialect.ToSql(Argument)
Dialect.GetOrderbyCollationHint()
Dialect.ToSql(GroupBy)
Dialect.ToSql(Count)
Dialect.ToSql(CountAll)
Dialect.ToSql(IsNull)
Dialect.ToSql(IsNotNull)
Dialect.EncodedArraySearch(Argument, Argument[], Dialect.EncodedArraySearchType, Dialect.FulltextEncodedSearch)
Dialect.ToSql(HasAny)
Dialect.ToSql(HasAll)
Dialect.ToSql(MissingAny)
Dialect.ToSql(MissingAll)
Dialect.ToSql(Between)
Dialect.ToSql(NotBetween)
Dialect.ToSql(TableInfo)
Dialect.ToSql(FieldInfo)
Dialect.ToSql(LessThan)
Dialect.ToSql(GreaterThan)
Dialect.ToSql(LessThanOrEqual)
Dialect.ToSql(GreaterThanOrEqual)
Dialect.ToSql(HasFlag)
Dialect.ToSql(HasNoFlag)
Dialect.ToSql(And)
Dialect.ToSql(Or)
Dialect.ParseMathematicalArguments(MathematicalExpression, string)
Dialect.ToSql(Greatest)
Dialect.ToSql(Subtract)
Dialect.ToSql(Multiply)
Dialect.ToSql(Divide)
Dialect.ToSql(LeftOuterJoin)
Dialect.ToSql(RightOuterJoin)
Dialect.ToSql(InnerJoin)
Dialect.ParseJoinClause(JoinRestriction)
Dialect.ToSql(Distinct)
Dialect.ToSql(Alias)
Dialect.ToSql(FieldDataType)
Dialect.ToSql(Upper)
Dialect.ToSql(Lower)
Dialect.ToSql(Trim)
Dialect.ToSql(Soundex)
Dialect.ToSql(Year)
Dialect.ToSql(Month)
Dialect.ToSql(Day)
Dialect.ToSql(Hour)
Dialect.ToSql(Minute)
Dialect.ToSql(Second)
Dialect.ToSql(Sum)
Dialect.ToSql(Max)
Dialect.ToSql(Min)
Dialect.TableOptions(TableInfo, SqlType)
Dialect.ConvertToDbString(string)
Dialect.TimeTUtc2DateTime(int)
Dialect.TimeTLocal2DateTime(int)
Dialect.DateTime2TimeTUtc(DateTime)
Dialect.DateTime2TimeTLocal(DateTime)
Dialect.SelectSql(PrivateSelect)
Dialect.ComposeSelect(string, string, string, string, StringBuilder, PrivateSelect)
Dialect.InsertSql(PrivateSave)
Dialect.UpdateSql(PrivateSave)
Dialect.DeleteSql(PrivateSave)
Dialect.UnionSql(TableExpression)
Dialect.PreParseUnion(TableExpression)
Dialect.DifferenceSql(TableExpression)
Dialect.GenerateSql(SqlCommand)
Dialect.FieldIsClob(Argument)
Dialect.FieldIsString(Argument)
Dialect.DataReaderGetName(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDataTypeName(SoDataReader, IDataReader, int)
Dialect.DataReaderGetFieldType(SoDataReader, IDataReader, int)
Dialect.DataReaderGetValue(SoDataReader, IDataReader, int)
Dialect.DataReaderGetOrdinal(SoDataReader, IDataReader, string)
Dialect.DataReaderGetNullValue(SoDataReader, int)
Dialect.DataReaderGetBoolean(SoDataReader, IDataReader, int)
Dialect.DataReaderGetByte(SoDataReader, IDataReader, int)
Dialect.DataReaderGetBytes(SoDataReader, IDataReader, int, long, byte[], int, int)
Dialect.DataReaderGetChar(SoDataReader, IDataReader, int)
Dialect.DataReaderGetChars(SoDataReader, IDataReader, int, long, char[], int, int)
Dialect.DataReaderGetGuid(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt32(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt32Array(SoDataReader, IDataReader, int)
Dialect.DataReaderGetInt64(SoDataReader, IDataReader, int)
Dialect.DataReaderGetFloat(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDouble(SoDataReader, IDataReader, int)
Dialect.DataReaderGetDecimal(SoDataReader, IDataReader, int)
Dialect.LockReader<T>(SoDataReader, Func<T>)
Dialect.DataReaderGetDateTime(SoDataReader, IDataReader, int)
Dialect.DataReaderGetData(SoDataReader, IDataReader, int)
Dialect.DataReaderIsDBNullAsync(SoDataReader, DbDataReader, int, CancellationToken)
Dialect.IntToSingleWord(int)
Dialect.IntArrayToWordString(params int[])
Dialect.IntFromSingleWord(string)
Dialect.IntArrayFromWordString(string)
Dialect.GetDefaultTransaction(SoConnection, SqlCommand)
Dialect.DataReaderIsDBNull(SoDataReader, DbDataReader, int)
Dialect.BlockUpperInOrderBy
Dialect.MaxInSize
Dialect.Tables
Dialect.ReturnDBFields
Dialect.HasAliasOnDelete
Dialect.HasAliasOnInsert
Dialect.HasAliasOnUpdate
Dialect.HasAliasOnSelect
Dialect.CurrentSqlType
Dialect.CurrentOuterSqlType
Dialect.ReturnFieldsIndexer
Dialect.VarcharType
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Data.Dialect
Assembly: SoDataBase.BusinessLogic.dll
Syntax
public class OracleCommon : Dialect

Properties

CaseSensitiveDatabase

Is the database case-sensitive by default (something we work hard to make disappear)?

Declaration
protected override bool CaseSensitiveDatabase { get; }
Property Value
Type Description
bool
Overrides
Dialect.CaseSensitiveDatabase

DefaultConnectionString

Default connection string for Oracle

Declaration
public override string DefaultConnectionString { get; }
Property Value
Type Description
string
Overrides
Dialect.DefaultConnectionString

Methods

CheckForDistinct(PrivateSelect)

Some databases (ORACLE!!) are unable to do DISTINCT over the datatype we use for our 2k text strings; in those cases we need to 'fake' a distinct. This method is called when generating the SQL text, and controls whether we should say "distinct" as part of the select

Declaration
public override bool CheckForDistinct(PrivateSelect cmd)
Parameters
Type Name Description
PrivateSelect cmd
Returns
Type Description
bool
Overrides
Dialect.CheckForDistinct(PrivateSelect)

CheckForDuplicateRow(IDataReader)

Some databases (ORACLE!!) are unable to do DISTINCT over the datatype we use for our 2k text strings; in those cases we need to 'fake' a distinct. This method is called from the SoDataReader to determine if the current row is such a duplicate.

Declaration
public override bool CheckForDuplicateRow(IDataReader reader)
Parameters
Type Name Description
IDataReader reader

Reader containing the row to be evaluated

Returns
Type Description
bool

If true, then this row is a duplicate of one that has been previously passed to this method

Overrides
Dialect.CheckForDuplicateRow(IDataReader)

ConvertFromDbType(object, FieldDataType)

Strings with one space on oracle should be an empty string.

Declaration
public override object ConvertFromDbType(object value, FieldDataType dataType)
Parameters
Type Name Description
object value

value of the field as returned from the database

FieldDataType dataType

data type of the field in the database.

Returns
Type Description
object

Value that can be casted to the default .net type representing the database type.

Overrides
Dialect.ConvertFromDbType(object, FieldDataType)
Exceptions
Type Condition
SoIllegalOperationException

Thrown if the data type is of an unsupported format.

ConvertToDbParameterType(object, FieldDataType)

This class contains the common SQL-syntax for the Oracle DB.

Declaration
public override object ConvertToDbParameterType(object value, FieldDataType dataType)
Parameters
Type Name Description
object value
FieldDataType dataType
Returns
Type Description
object
Overrides
Dialect.ConvertToDbParameterType(object, FieldDataType)

ConvertToDbType(object, FieldDataType)

Empty strings are saved by SuperOffice on Oracle databases as a space, so we override this.

Declaration
public override string ConvertToDbType(object value, FieldDataType dataType)
Parameters
Type Name Description
object value

The value to convert.

FieldDataType dataType

The data type of the value in the database.

Returns
Type Description
string

A string that can be used in a database SQL command.

Overrides
Dialect.ConvertToDbType(object, FieldDataType)
Exceptions
Type Condition
SoIllegalOperationException

Thrown if the data type is of an unsupported format.

DataReaderGetInt16(SoDataReader, IDataReader, int)

Gets the value of the specified column as a 16-bit signed integer.

Declaration
public override short DataReaderGetInt16(SoDataReader soReader, IDataReader innerReader, int i)
Parameters
Type Name Description
SoDataReader soReader

DataReader to read from.

IDataReader innerReader

inner data reader

int i

column index

Returns
Type Description
short

the integer or 0 if null

Overrides
Dialect.DataReaderGetInt16(SoDataReader, IDataReader, int)

DataReaderGetItem(SoDataReader, IDataReader, int)

Oracle specific data read - does some special Oracle handling on number columns

Declaration
protected override object DataReaderGetItem(SoDataReader soReader, IDataReader innerReader, int i)
Parameters
Type Name Description
SoDataReader soReader

outer reader

IDataReader innerReader

inner reader

int i

column index

Returns
Type Description
object

number, string or whatever

Overrides
Dialect.DataReaderGetItem(SoDataReader, IDataReader, int)

DataReaderGetString(SoDataReader, IDataReader, int)

Gets the value of the specified column as a string.

Declaration
public override string DataReaderGetString(SoDataReader soReader, IDataReader innerReader, int i)
Parameters
Type Name Description
SoDataReader soReader

DataReader to read from.

IDataReader innerReader
int i
Returns
Type Description
string
Overrides
Dialect.DataReaderGetString(SoDataReader, IDataReader, int)

DateToVarchar(string)

Subclass override: How to convert a datetime to a varchar (or whatever it's called), in the database, taking only the DATE part

Declaration
protected override string DateToVarchar(string innerValue)
Parameters
Type Name Description
string innerValue

The actual reference to the datetime to work on; this is an opaque parameter that the method should NOT attempt to understand, just assume it will be a valid datetime value or parameter at query-execution time

Returns
Type Description
string
Overrides
Dialect.DateToVarchar(string)

GetIsolationLevel(IsolationLevel)

The oracle databases only support ReadCommitted or Serializable through the Microsoft Oracle data provider.

Declaration
public override IsolationLevel GetIsolationLevel(IsolationLevel requestedLevel)
Parameters
Type Name Description
IsolationLevel requestedLevel

Requested isolation level

Returns
Type Description
IsolationLevel

Chaos, ReadUncommitted and ReadCommitted result in ReadCommitted. All other result in Serializable.

Overrides
Dialect.GetIsolationLevel(IsolationLevel)

TimeToVarchar(string)

Subclass override: How to convert a datetime to a varchar (or whatever it's called), in the database, taking only the TIME part

Declaration
protected override string TimeToVarchar(string innerValue)
Parameters
Type Name Description
string innerValue

The actual reference to the datetime to work on; this is an opaque parameter that the method should NOT attempt to understand, just assume it will be a valid datetime value or parameter at query-execution time

Returns
Type Description
string
Overrides
Dialect.TimeToVarchar(string)

ToSql(Add)

The Add-operator will return the correct field and its correct sqlOperator.

T0.associate_id = T0.associate_id + 1;
Declaration
protected override string ToSql(Add arg)
Parameters
Type Name Description
Add arg

The Add-argument

Returns
Type Description
string

The parsed Add operation as a string expression.

Overrides
Dialect.ToSql(Add)

ToSql(DateAdd)

This class contains the common SQL-syntax for the Oracle DB.

Declaration
protected override string ToSql(DateAdd arg)
Parameters
Type Name Description
DateAdd arg
Returns
Type Description
string
Overrides
Dialect.ToSql(DateAdd)

ToSql(Equal)

left = right or UPPER(left) = UPPER(right) for case-insensitive string searches

The text-field in the database is of type CLOB. It is not possible to use the EQUAL operator on this type, and conversions to VARCHAR via the DBMS_LOB.SUBSTR will fail if the data in the table expands to more than 4000 bytes. Fortunately the LIKE operator does work in these circumstances, so we'll use it.
Declaration
protected override string ToSql(Equal arg)
Parameters
Type Name Description
Equal arg

The EQUAL arguments.

Returns
Type Description
string

A parsed and build sql string according with the necessary alterations if dealing with a clob-field.

Overrides
Dialect.ToSql(Equal)

ToSql(FieldTypeConvert)

ToSql( FieldTypeConvert arg ) parse the FieldTypeConvert-part of an sql-command and returns the correct database-specific syntax for the conversion.

Declaration
protected override string ToSql(FieldTypeConvert arg)
Parameters
Type Name Description
FieldTypeConvert arg

The argument to parse.

Returns
Type Description
string

A parsed sql-statement corresponding to the incoming argument.

Overrides
Dialect.ToSql(FieldTypeConvert)

ToSql(In)

Oracle needs special handling of the In-operator.

Declaration
protected override string ToSql(In arg)
Parameters
Type Name Description
In arg

The In-argument to parse.

Returns
Type Description
string

A parsed sql-statement corresponding to the incoming argument.

Overrides
Dialect.ToSql(In)
Remarks

If the number of parameters in the In-clause are equal to 1, it prefers that the equal-operator is used instead. ToSql( In arg ) checks the number of arguments and does one of two. Call the base-class ToSql( In arg )-method or cast the in-parameter as an UnEqual-object. Then we call the ToSql( UnEqual arg ) method.

ToSql(JsonValue)

Oracle requires the second parameter (the Path) to be a literal, part of the SQL. Variables are not supported

Declaration
protected override string ToSql(JsonValue arg)
Parameters
Type Name Description
JsonValue arg
Returns
Type Description
string
Overrides
Dialect.ToSql(JsonValue)
Remarks

Sql injection risk? The JsonValue constructor has strict filtering of the legal path characters.

ToSql(Like)

Case insensitive LIKE operator on Oracle database. Note that = is case sensitive on Oracle.

Declaration
protected override string ToSql(Like arg)
Parameters
Type Name Description
Like arg

The Like argument

Returns
Type Description
string

UPPER(left) LIKE UPPER(right)

Overrides
Dialect.ToSql(Like)
Remarks

We add UPPER on both sides of the LIKE operator.

ToSql(NotIn)

Oracle needs special handling of the NotIn-operator.

Declaration
protected override string ToSql(NotIn arg)
Parameters
Type Name Description
NotIn arg

The NotIn-argument to parse.

Returns
Type Description
string

A parsed sql-statement corresponding to the incoming argument.

Overrides
Dialect.ToSql(NotIn)
Remarks

If the number of parameters in the NotIn-clause are equal to 1, it prefers that the not equal-operator is used instead. ToSql( NotIn arg ) checks the number of arguments and does one of two. Call the base-class ToSql( NotIn arg )-method or cast the NotIn-parameter as an UnEqual-object. Then we call the ToSql( UnEqual arg ) method.

ToSql(NotLike)

Common handling of the NotLike operator on Oracle database.

Declaration
protected override string ToSql(NotLike arg)
Parameters
Type Name Description
NotLike arg

The Not Like argument

Returns
Type Description
string

A parsed sql-statement corresponding to the incoming argument.

Overrides
Dialect.ToSql(NotLike)
Remarks

We add UPPER on both sides of the operator.

ToSql(OrderBy)

The Order By is used when you want your data shown in a specific order. On Oracle, CLOB fields need to be converted to more "ordinary" substrings before they can be used for orderby

Declaration
protected override string ToSql(OrderBy arg)
Parameters
Type Name Description
OrderBy arg

The OrderBy clause

Returns
Type Description
string

The Order By sql-clause.

Overrides
Dialect.ToSql(OrderBy)

ToSql(Parameter)

Return a parameter

Declaration
protected override string ToSql(Parameter arg)
Parameters
Type Name Description
Parameter arg

the Parameter argument

Returns
Type Description
string
Overrides
Dialect.ToSql(Parameter)

ToSql(UnEqual)

The text-field in the database is of type CLOB. It is not possible to use the UNEQUAL operator on this type, and conversions to VARCHAR via the DBMS_LOB.SUBSTR will fail if the data in the table expands to more than 4000 bytes. Fortunately the LIKE operator does work in these circumstances, so we'll use it.

Declaration
protected override string ToSql(UnEqual arg)
Parameters
Type Name Description
UnEqual arg

The UNEQUAL argument.

Returns
Type Description
string

A parsed and build sql string according with the necessary alterations if dealing with a clob-field.

Overrides
Dialect.ToSql(UnEqual)

ToSql(WaitFor)

This class contains the common SQL-syntax for the Oracle DB.

Declaration
protected string ToSql(WaitFor arg)
Parameters
Type Name Description
WaitFor arg
Returns
Type Description
string

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top