当前位置:网站首页>Chapter VI data type (V)

Chapter VI data type (V)

2022-06-12 11:55:00 yaoxin521123

Chapter six data type ( 5、 ... and )

Integer code of data type

In query metadata and other contexts , The data type defined for the column can be returned as an integer code . CType( Client data type ) Integer codes are listed in %SQL.StatementColumnclientType Properties of the .

ODBC and JDBC Use xDBC Data type code (SQLType). ODBC The data type code is defined by %SQL.Statement.%Metadata.columns.GetAt() Method returns , As shown in the example above . SQL Shell Metadata also returns ODBC Data type code . JDBC Code and the ODBC Same code , In addition to the representation of time and date data types . These are listed below ODBC and JDBC value :

ODBCJDBCData Type
-11-11GUID
-7-7BIT
-6-6TINYINT
-5-5BIGINT
-4-4LONGVARBINARY
-3-3VARBINARY
-2-2BINARY
-1-1LONGVARCHAR
00Unknown type
11CHAR
22NUMERIC
33DECIMAL
44INTEGER
55SMALLINT
66FLOAT
77REAL
88DOUBLE
991DATE
1092TIME
1193TIMESTAMP
1212VARCHAR

IRIS It also supports the use of multi byte character sets ODBC Application's Unicode SQL type , For example, Chinese 、 Hebrew 、 Japanese or Korean language environment .

ODBCData Type
-10WLONGVARCHAR
-9WVARCHAR

Create user defined DDL data type

You can modify the data type set by overriding the data type mapping of the system data type parameter value or defining a new user data type . The system data type can be modified to override Default mapping . You can create user-defined data types to provide Other data type mappings not provided .

To view and modify or add to the current user data type mapping , Please go to the administration portal , Choose system management 、 To configure 、SQL And object settings 、 user DDL mapping . To add a user data type , Please select to create a new user-defined DDL mapping . In the displayed box , Enter a name , for example VARCHAR(100) And data types , for example MyString100(MAXLEN=100).

The result will be user-defined DDL An entry in the data type list .

User defined data types can be created as data type classes . for example , You may want to create a maximum of 10 Character string data type , Then truncate the rest of the input data . This data type will be created Sample.TruncStr, As shown below :

Class Sample.TruncStr Extends %Library.String
  {
  Parameter MAXLEN=10;
  Parameter TRUNCATE=1;
  }

To use this data type in a table definition , Just specify the data type class name :

CREATE TABLE Sample.ShortNames (Name Sample.TruncStr)

As shown in the previous example , There are several useful routines for entering user-defined DDL data type :

  • maxval^%apiSQL() — Given precision and scale , Return each IRIS The maximum valid value of a numeric data type (MAXVAL). Grammar is :
     maxval^%apiSQL(precision,scale)
  • minval^%apiSQL() — Given precision and scale , Return each IRIS The least significant value of a numeric data type (MINVAL). Grammar is :
     minval^%apiSQL(precision,scale)

If necessary DDL The data type maps to a collection type of Stream Of IRIS attribute , Please specify... For character stream data %Stream.GlobalCharacter, Specify... For binary stream data %Stream.GlobalBinary.

If you can't find it DDL mapping , Then pass on

If DDL Encountered not in SystemDataTypes Tabular DDL Data types in the data type column , It then checks UserDataTypes surface . If there is no mapping for any data type in any table , No data type conversion will occur , And the data type will be passed directly to DDL Class definitions specified in .

for example , The following field definitions may appear in DDL In the sentence :

     CREATE TABLE TestTable (
          Field1 %String,
          Field2 %String(MAXLEN=45)
          )

In view of the above definition , If DDL stay SystemDataTypes or UserDataTypes I can't find it in China. %String or %String(MAXLEN=%1) or %String(MAXLEN=45) Mapping , Then pass on %String and %String(MAXLEN=45) Type directly to the appropriate class definition .

Convert data type

To convert data from one data type to another , Please use CAST or CONVERT function .

CAST Support conversion to multiple string and numeric data types , as well as DATETIME as well as TIMESTAMP and POSIXTIME Timestamp data type .

CONVERT There are two forms of grammar . Both forms support and DATETIME as well as TIMESTAMP and POSIXTIME Conversion between timestamp data types , And other data types .

VARCHAR Of CAST and CONVERT Handle

VARCHAR data type ( No size specified ) Mapping to 1 A character MAXLEN, As shown in the table above . however , When CAST or CONVERT Convert the value to VARCHAR when , The default size mapping is 30 Characters . Provide this 30 The default size of characters is for non - IRIS The software requires compatibility .

原网站

版权声明
本文为[yaoxin521123]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121143094655.html