Skip to main content

%TSQL.Impl

Class %TSQL.Impl Extends %RegisteredObject [ System = 4 ]

Implementation of TSQL scalar and other functions not supported by SQL

Methods

CHARINDEX

ClassMethod CHARINDEX(ToFind As %String, FindIn As %String, StartAt As %Integer = 1) As %String [ SqlName = CHARINDEX, SqlProc ]

Implement CHARINDEX(tofind,findin[,startat])

DATALENGTH

ClassMethod DATALENGTH(Item) As %Integer [ SqlName = DATALENGTH, SqlProc ]

Implement DATALENGTH(item)

ZWITHDATETIME

ClassMethod ZWITHDATETIME(Item As %String) As %String [ SqlName = ZWITHDATETIME, SqlProc ]

Implement ZWITHDATETIME(item) to append a date of 1/1/1900 and/or a time of midnight to the item if necessary

ZREMAMPM

ClassMethod ZREMAMPM(Item) As %String [ SqlName = ZREMAMPM, SqlProc ]

Implement ZREMAMPM(item) to remove the "AM" or "PM" if necessary

ZBITWISEOR

ClassMethod ZBITWISEOR(A, B) As %Integer [ SqlName = ZBITWISEOR, SqlProc ]

Implement bitwiseOR

ZBITWISEAND

ClassMethod ZBITWISEAND(A, B) As %Integer [ SqlName = ZBITWISEAND, SqlProc ]

Implement bitwiseAND

ZBITWISEXOR

ClassMethod ZBITWISEXOR(A, B) As %Integer [ SqlName = ZBITWISEXOR, SqlProc ]

Implement bitwiseXOR

ZCONVERRFROMTSQL

ClassMethod ZCONVERRFROMTSQL(A) As %Integer [ SqlName = ZCONVERRFROMTSQL, SqlProc ]

Translate a TSQL error code to a SQLCODE

ZFORMATMESSAGE

ClassMethod ZFORMATMESSAGE(Message, Args...) [ SqlName = ZFORMATMESSAGE, SqlProc ]

Format a RAISERROR message with the given arguments

ZLIKETOCOSPATTERNS

ClassMethod ZLIKETOCOSPATTERNS(LikePattern As %String, LikeEscape As %String = "") As %String [ SqlName = ZLIKETOCOSPATTERNS, SqlProc ]

Given a LIKE pattern and optional LIKE ESCAPE, return the corresponding COS pattern (SQL strings)

ZLIKETOCOSPATTERN

ClassMethod ZLIKETOCOSPATTERN(LikePattern As %String, LikeEscape As %String = "") As %String [ CodeMode = expression ]

Given a LIKE pattern and optional LIKE ESCAPE, return the corresponding COS pattern (non-SQL strings)

ZLIKETOCOSPATTERNLIST

ClassMethod ZLIKETOCOSPATTERNLIST(LikePattern As %String, LikeEscape As %String = "") As %List [ Private, SqlName = ZLIKETOCOSPATTERNLIST, SqlProc ]

Given a LIKE pattern and optional LIKE ESCAPE, return a list of top-level COS pattern elements

ExtractRangeText

ClassMethod ExtractRangeText(LikePattern As %String, LikeEscape As %String, ByRef Pos As %Integer) As %String [ Private ]

Given the position just after the "["

Return with the position just after the "]" - or after the end of the string if there is no "]"

Return the raw range text (with relevant escapes for "-" and the escape character itself still in place)

AnalyseRangePattern

ClassMethod AnalyseRangePattern(RangeText As %String, LikeEscape As %String) As %String [ Private ]

Given RangeText with what appeared between [..] with the escapes for LikeEscape and "-" intact

Return a COS pattern fragment which matches the range

RangeToPattern

ClassMethod RangeToPattern(Range As %List) As %String [ Private ]

Find

ClassMethod Find(LookIn As %String, LookFor As %String, StartLook As %Integer = 1)

Look for LookIn in LookFor starting at StartLook (defaults to 1)

If the string isn't found then 0 is returned

If the string is found then the 1-based offset to the start of LookFor in LookIn is returned

CompareStringPos3

ClassMethod CompareStringPos3(N1 As %Integer, N2 As %Integer, N3 As %Integer, Tags As %List) As %Integer [ Private ]

N1-N3 are COS string positions, 1-based and 0 means not found

If one of the positions is undisputedly earliest of the three its tag is returned

otherwise return 0

CompareStringPos2

ClassMethod CompareStringPos2(N1 As %Integer, N2 As %Integer, Tags As %List) As %Integer [ Private ]

N1-N2 are COS string positions, 1-based and 0 means not found

If one of the positions is undisputedly earlier its tag is returned

otherwise return 0

STUFF

ClassMethod STUFF(SourceString As %String, StartPos As %Integer, ReplaceLength As %Integer, ReplaceString As %String) As %String [ SqlName = STUFF, SqlProc ]

Implement STUFF(sourcestring,startpos,replacelength,replacestring)

ZRAND

ClassMethod ZRAND(ScaleFactor As %Integer) As %Float [ CodeMode = expression, SqlName = ZRAND, SqlProc ]

Implement ZRAND(scalefactor)

ZRPATINDEX

ClassMethod ZRPATINDEX(TsqlPattern As %String, Expr As %String) As %Integer [ SqlName = ZRPATINDEX, SqlProc ]

PATINDEX for non-literal patterns

ZRPATINDEXPLP

ClassMethod ZRPATINDEXPLP(TsqlInnerPattern As %String, Expr As %String) As %Integer [ SqlName = ZRPATINDEXPLP, SqlProc ]

PATINDEX for "%"+XXX+"%" patterns

ZPATINDEXPL

ClassMethod ZPATINDEXPL(LiteralPart As %String, Expr As %String) As %Integer [ SqlName = ZPATINDEXPL, SqlProc ]

PATINDEX for: percent literal - returns 0/position of literal

ZPATINDEXPLR

ClassMethod ZPATINDEXPLR(LiteralPart As %String, CosPattern As %String, Expr As %String) As %Integer [ SqlName = ZPATINDEXPLR, SqlProc ]

PATINDEX for: percent literal rest - 0/returns position of literal

ZPATINDEXPN

ClassMethod ZPATINDEXPN(CosPattern As %String, Expr As %String) As %Integer [ SqlName = ZPATINDEXPN, SqlProc ]

PATINDEX for: percent non-literal - returns 0/position of non-literal

ZPATINDEXU

ClassMethod ZPATINDEXU(UnderlineCount As %Integer, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXU, SqlProc ]

PATINDEX for: underline(s) - returns 0/1

ZPATINDEXUL

ClassMethod ZPATINDEXUL(UnderlineCount As %Integer, LiteralPart As %String, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXUL, SqlProc ]

PATINDEX for: underline(s) literal - returns 0/1

ZPATINDEXULR

ClassMethod ZPATINDEXULR(UnderlineCount As %Integer, LiteralPart As %String, CosPattern As %String, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXULR, SqlProc ]

PATINDEX for: underline(s) literal rest - returns 0/1

ZPATINDEXL

ClassMethod ZPATINDEXL(LiteralPart As %String, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXL, SqlProc ]

PATINDEX for: literal - returns 0/1

ZPATINDEXLR

ClassMethod ZPATINDEXLR(LiteralPart As %String, CosPattern As %String, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXLR, SqlProc ]

PATINDEX for: literal rest - returns 0/1

ZPATINDEXFB

ClassMethod ZPATINDEXFB(CosPattern As %String, Expr As %String) As %Integer [ CodeMode = expression, SqlName = ZPATINDEXFB, SqlProc ]

PATINDEX for anything that isn't covered above (FB=fallback) - returns 0/1

- will not give the correct result for a pattern beginning with "%"

FLOOR

ClassMethod FLOOR(Number As %String) As %Numeric [ CodeMode = expression ]

Implement FLOOR for COS context

LEN

ClassMethod LEN(Str As %String) As %Integer [ CodeMode = expression ]

Implement LEN for COS context

SUBSTRING

ClassMethod SUBSTRING(Item, Start, Length) As %String [ SqlName = SUBSTRING, SqlProc ]

Implement SUBSTRING(item, start, length)

REPLACE

ClassMethod REPLACE(Expr As %String, Old As %String, New As %String) As %String [ SqlName = REPLACE, SqlProc ]

Implement REPLACE(expr,old,new)

ZPATTERNMATCH

ClassMethod ZPATTERNMATCH(Expr As %String, CosPattern As %String) As %Integer [ SqlName = ZPATTERNMATCH, SqlProc ]

IFNULL

ClassMethod IFNULL(Expr1 As %String, Expr2 As %String, Expr3 As %String = "") As %String [ CodeMode = expression, SqlName = IFNULL, SqlProc ]

Implement IFNULL(expr1,expr2[,expr3])

IsStream

ClassMethod IsStream(Value As %String, ByRef StreamOref) As %Boolean

Is the given value a stream id?

- if so: return 1 and set StreamOref

- otherwise: return 0 and set StreamOref to $$$NULLOREF

ROUND

ClassMethod ROUND(Number As %Numeric, Length As %Integer, Function As %Integer) As %String [ SqlName = ROUND, SqlProc ]

Implement ROUND(number,length,function)