%SQL.StatementMetadata
class %SQL.StatementMetadata extends %Library.RegisteredObject
For details on using this class, see SQL Metadata.
Metadata describes the statement interface. The statement metadata contains the type of statement, the number of columns defined by the statement and the metadata for each column. Statement columns are of three primary types: result columns, parameters, and the return value. There is also a distinction between the metadata available for a prepared statement and for a statement that has been executed since not all statement results are known at prepare time. For all statement types except CALL, the statement metadata is all available at prepare time. CALL statement metadata that is available at prepare time includes the metadata from the statement itself and that metadata is not to be confused with the metadata defined by the SQL routine that is called. Each routine defines a formal interface that consists of an optional return value and option input, input-output and output parameters. An SQL routine might also return a single preplanned result set. That metadata is available at prepare time and it consists of some number of columns of type SQLRESULTCOL. An SQL routine might also declare that it returns some dynamic result sets, the metadata for which is not available until after the statement is executed and the result sets bound dynamic cursors.Property Inventory
- columnCount
- columnIndex
- columns
- formalParameters
- interface
- objects
- parameterCount
- parameters
- statementType
Method Inventory
Properties
property columnCount as %Integer;
The number of columns defined as SQLRESULTCOL that are returned by executing this statement.
This is the same as columns.Count().
Property methods: columnCountDisplayToLogical(), columnCountGet(), columnCountIsValid(), columnCountLogicalToDisplay(), columnCountNormalize(), columnCountSet()
property columnIndex as %String) [ MultiDimensional ];
Index on column names and column number.
Property methods: columnIndexDisplayToLogical(), columnIndexGet(), columnIndexIsValid(), columnIndexLogicalToDisplay(), columnIndexLogicalToOdbc(), columnIndexNormalize(), columnIndexSet()
property columns as list of %SQL.StatementColumn;
columns is a collection of StatementColumn objects. Each StatementColumn object
contains the metadata a column defined by the statement as an SQLRESULTCOL column type.
Property methods: columnsBuildValueArray(), columnsCollectionToDisplay(), columnsCollectionToOdbc(), columnsDisplayToCollection(), columnsGet(), columnsGetObject(), columnsGetObjectId(), columnsGetSwizzled(), columnsIsValid(), columnsOdbcToCollection(), columnsSet(), columnsSetObject(), columnsSetObjectId()
property formalParameters as list of %SQL.StatementParameter;
formalParameters is a collection of '?' parameters found in the prepared statement.
It may differ from the parameters collection if literal replacement occurred. This
property is mainly for internal use and metadata reporting. It is not meant to be used
for the statement descriptor.
Property methods: formalParametersBuildValueArray(), formalParametersCollectionToDisplay(), formalParametersCollectionToOdbc(), formalParametersDisplayToCollection(), formalParametersGet(), formalParametersGetObject(), formalParametersGetObjectId(), formalParametersGetSwizzled(), formalParametersIsValid(), formalParametersOdbcToCollection(), formalParametersSet(), formalParametersSetObject(), formalParametersSetObjectId()
property interface as %Integer;
interface is an integer value indicating the routine interface:
-2 - Return value, dynamic cursors returned (zero, one or more)
-1 - No return value, dynamic cursors returned (RETURNRESULTSETS, zero one or more)
0 - No return value, no dynamic cursors (NOT RETURNRESULTSETS, aka "function" procedure although a function should return a value (interface = 2))
1 - No return value, one pre-planned result set (AKA "query" procedure)
2 - Return value, no dynamic cursors (NOT RETURNRESULTSETS)
Property methods: interfaceDisplayToLogical(), interfaceGet(), interfaceIsValid(), interfaceLogicalToDisplay(), interfaceNormalize(), interfaceSet()
property objects as list of %SQL.StatementObject;
A collection of StatementObject objects representing the columns that are object values.
Property methods: objectsBuildValueArray(), objectsCollectionToDisplay(), objectsCollectionToOdbc(), objectsDisplayToCollection(), objectsGet(), objectsGetObject(), objectsGetObjectId(), objectsGetSwizzled(), objectsIsValid(), objectsOdbcToCollection(), objectsSet(), objectsSetObject(), objectsSetObjectId()
property parameterCount as %Integer;
The number of parameters defined in this statement. This is the same as
parameters.Count().
Property methods: parameterCountDisplayToLogical(), parameterCountGet(), parameterCountIsValid(), parameterCountLogicalToDisplay(), parameterCountNormalize(), parameterCountSet()
property parameters as list of %SQL.StatementParameter;
The parameters collection contains the metadata for each actual parameter
contained in the source statement. ..parameters.Count() is equivalent to the
number of '?' parameters found in the source statement and the list position
corresponds to the ordinal position of the '?' in the source statement.
Property methods: parametersBuildValueArray(), parametersCollectionToDisplay(), parametersCollectionToOdbc(), parametersDisplayToCollection(), parametersGet(), parametersGetObject(), parametersGetObjectId(), parametersGetSwizzled(), parametersIsValid(), parametersOdbcToCollection(), parametersSet(), parametersSetObject(), parametersSetObjectId()
property statementType as %Integer;
Integer value indicating the type of statement.
1 | SELECT |
2 | INSERT (also 'INSERT OR UPDATE') |
3 | UPDATE |
4 | DELETE |
5 | COMMIT |
6 | ROLLBACK |
7 | GRANT |
8 | REVOKE |
9 | CREATE TABLE |
10 | ALTER TABLE |
11 | DROP TABLE |
12 | CREATE VIEW |
13 | ALTER VIEW |
14 | DROP VIEW |
15 | CREATE INDEX |
16 | ALTER INDEX (Not supported) |
17 | DROP INDEX |
18 | CREATE ROLE |
19 | DROP ROLE |
20 | SET TRANSACTION |
21 | START TRANSACTION |
22 | %INTRANSACTION |
23 | %BEGTRANS (Alias for START TRANSACTION) |
24 | %INTRANS (Alias for %INTRANSACTION) |
25 | GET (Not supported) |
26 | SET OPTION |
27 | STATISTICS (UPDATE STATISTICS, not supported)) |
28 | %CHECKPRIV |
29 | CREATE USER |
30 | ALTER USER |
31 | DROP USER |
32 | %CHECKPRIV (SQL Admin Privilege) |
33 | GRANT (SQL Admin Privilege) |
34 | REVOKE (SQL Admin Privilege) |
35 | CREATE FUNCTION |
36 | CREATE METHOD |
37 | CREATE PROCEDURE |
38 | CREATE QUERY |
39 | DROP FUNCTION |
40 | DROP METHOD |
41 | DROP PROCEDURE |
42 | DROP QUERY |
43 | CREATE TRIGGER |
44 | DROP TRIGGER |
45 | CALL |
46 | SAVEPOINT |
47 | LOCK TABLE |
48 | UNLOCK TABLE |
49 | CREATE DATABASE |
50 | DROP DATABASE |
51 | USE DATABASE |
52 | TUNE TABLE |
53 | DECLARE |
54 | CREATE MODEL |
55 | DROP MODEL |
56 | TRAIN MODEL |
57 | ALTER MODEL |
58 | VALIDATE MODEL |
59 | SET ML CONFIGURATION |
60 | CREATE ML CONFIGURATION |
61 | ALTER ML CONFIGURATION |
62 | DROP ML CONFIGURATION |
63 | FREEZE PLANS |
64 | UNFREEZE PLANS |
65 | PURGE |
66 | BUILD INDEX |
67 | CREATE AGGREGATE |
68 | DROP AGGREGATE |
69 | LOAD |
70 | CREATE SCHEMA |
71 | DROP SCHEMA |
72 | CREATE SERVER |
73 | ALTER SERVER |
74 | DROP SERVER |
75 | CREATE FOREIGN TABLE |
76 | ALTER FOREIGN TABLE |
77 | DROP FOREIGN TABLE |
78 | CANCEL QUERY |
79 | EXPLAIN |
99 | Anything not list above |
Property methods: statementTypeDisplayToLogical(), statementTypeGet(), statementTypeIsValid(), statementTypeLogicalToDisplay(), statementTypeNormalize(), statementTypeSet()
Methods
method %Display() as %Status
Display metadata on the current device.
classmethod %GenerateMetadata(ByRef pInfo As %Binary, pStatementType As %Integer = 0, ByRef pMetadata As %Binary, ByRef pParameters As %Binary = "", ByRef pObjects As %Binary, ByRef pActual As %List = "", ByRef pDynamic As %List = "") as %Status
GenerateMetadata constructs the serialized metadata from the query processor's info array.
IF %protocol 41 and higher:
metadata = $lb()
1 - # of SELECT columns
2 - i:
1) Name
2) ODBC Type
3) Precision
4) Scale
5) NULLABLE (integer)
6) Column Label (same as Name)
7) Column Table Name
8) Column Schema Name
9) Column Qualifier Name - NULL
10) $Char(1)/$Char(0) string / $Extract position:
1) isAutoIncrement
2) isCaseSensitive
3) isCurrency
4) IsReadOnly
5) IsRowVersion
6) IsUnique
7) IsAliased
8) IsExpression
9) IsHidden
10) IsIdentity
11) IsKeyColumn
12) IsRowid
13) IsList
j - # of Parameters
j+1 - k:
1) ODBC Type
2) Precision
3) Scale
4) NULLABLE
5) colName
6) colType
IF %protocol less than 41:
metadata = $lb()
1 - # of SELECT columns
2 - i:
1) Name
2) ODBC Type
3) Precision
4) Scale
5) NULLABLE
6) Column Label (same as Name)
7) Column Table Name
8) Column Schema Name
9) Column Qualifier Name - NULL
j - # of Parameters
j+1 - k:
1) ODBC Type
2) Precision
3) Scale
4) NULLABLE
method printMetadata(pMetadata As %RawString) as %Status
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()