ECSQL Built-In functions
Following is list of built-in scalar functions
ECSQL allows use of these built-in functions:
ec_classname()
- Gets the formatted/qualified class name, given ECClassId as inputec_classid())
- Gets ECClassId, given a formatted/qualified class name as inputregexp()
- test if a text matches a regex.regexp_extract()
- extract and rewrite matching regex group from a string value.strToGuid()
- covert string guid to binary guid.guidToStr()
- covert binary guid to string guid.navigation_value()
- Constructs an ECNavigation value, given ECNavigation property, Id and optionaly, RelECClassId.
ec_classname( ecclassId [, format-string | format-id] )
For the specified ecClassId, returns the class name as a string formatted according to the specified format-string
Parameters
ecclassId
: An integer which could be a constant, column or a parameter.
format-string | format-id
: Optional format specifier and could be one of the following values. NULL
is also valid value, if specified the default format will be used
format-id | format-string | output |
---|---|---|
0 | s:c |
BisCore:Element (default) |
1 | a:c |
bis:Element |
2 | s |
BisCore |
3 | a |
bis |
4 | c |
Element |
5 | s.c |
BisCore.Element |
6 | a.c |
bis.Element |
Returns
className as specified by format, or NULL
if it was unable to resolve ECClassId
, or if the format specifier was not recognized.
Note that this can also cause ECSqlStatement::Step()
to return BE_SQLITE_ERROR
if the incorrect number of arguments was passed in.
Example
ec_classId('schema-name-or-alias : | . classname' )
For the specified (qualified) class name, returns the ECCassId
.
Note that this function can also take in two arguments - in the following form where schema-name-or-alias and classname can be specified separately.
ec_classid[ '<schema-name-or-alias>', '<classname>')
Parameters
Can take either one or two parameters:
schema-name-or-alias
: Schema name or alias e.g. bis (alias) or BisCore (name)
class-name
: Name of the class e.g. Element
Returns
An integer ECClassId
or NULL
if the name could not be resolved.
Note that this can also cause ECSqlStatement::Step()
to return BE_SQLITE_ERROR
if the incorrect number of arguments was passed in.
Example
REGEXP ( regex, value )
Regex uses google/re2 engine.
REGEXP_EXTRACT ( value, regex [, rewrite] )
Regex uses google/re2 engine.
This function can be used to extract or rewrite the output. Parameter rewrite
is made of group reference where \0
refer to text captured by whole regex specified. \1
, \2
...
refer to regex capture group in that order.
StrToGuid( guid-string )
When GUID
is stored as a binary, it needs to be converted for comparison purposes.
GuidToString( binary-guid )
When GUID
is stored as a binary, it needs to be converted for comparison purpose.
NAVIGATION_VALUE( ECNavigationProperty-path, Id [, RelECClassId] )
Constructs an ECNavigation property from the provided values.
Parameters
Can take either two or three parameters:
ECNavigationProperty-path
: The path must consist of Schema name or alias, Class name and Property Name. The property should always be an ECNavigation property.
Id
: The Id that will be applied to the ECNavigation value
RelECClassId
: The RelECClassId that will be applied to the ECNavigation value
The RelECClassId
argument is optional and when it is missing, the RelECClassId will be taken from the ECNavigationProperty ECRelationship class
Returns
The function returns an ECNavigation property.
Example
Last Updated: 29 April, 2025