This project has retired. For details please refer to its Attic page.
tmudr: tmudr::TypeInfo Class Reference

tmudr::TypeInfo Class Reference

Data types in the UDR interface. More...

#include <sqludr.h>

Inherits tmudr::TMUDRSerializableObject.

Public Types

enum  SQLTypeCode { ,
  SMALLINT, INT, LARGEINT, NUMERIC,
  DECIMAL_LSE, SMALLINT_UNSIGNED, INT_UNSIGNED, NUMERIC_UNSIGNED,
  DECIMAL_UNSIGNED, REAL, DOUBLE_PRECISION, CHAR,
  VARCHAR, DATE, TIME, TIMESTAMP,
  INTERVAL, BLOB, CLOB
}
enum  SQLTypeClassCode {
  CHARACTER_TYPE, NUMERIC_TYPE, DATETIME_TYPE, INTERVAL_TYPE,
  LOB_TYPE, UNDEFINED_TYPE_CLASS
}
enum  SQLTypeSubClassCode {
  FIXED_CHAR_TYPE, VAR_CHAR_TYPE, EXACT_NUMERIC_TYPE, APPROXIMATE_NUMERIC_TYPE,
  DATE_TYPE, TIME_TYPE, TIMESTAMP_TYPE, YEAR_MONTH_INTERVAL_TYPE,
  DAY_SECOND_INTERVAL_TYPE, LOB_SUB_CLASS, UNDEFINED_TYPE_SUB_CLASS
}
enum  SQLCharsetCode { , CHARSET_ISO88591, CHARSET_UTF8, CHARSET_UCS2 }
enum  SQLCollationCode { UNDEFINED_COLLATION, SYSTEM_COLLATION }
enum  SQLIntervalCode

Public Member Functions

 TypeInfo (const TypeInfo &type)
 TypeInfo (SQLTypeCode sqltype=UNDEFINED_SQL_TYPE, int length=0, bool nullable=false, int scale=0, SQLCharsetCode charset=CHARSET_UTF8, SQLIntervalCode intervalCode=UNDEFINED_INTERVAL_CODE, int precision=0, SQLCollationCode collation=SYSTEM_COLLATION)
SQLTypeCode getSQLType () const
SQLTypeClassCode getSQLTypeClass () const
SQLTypeSubClassCode getSQLTypeSubClass () const
bool getIsNullable () const
int getScale () const
SQLCharsetCode getCharset () const
SQLIntervalCode getIntervalCode () const
int getPrecision () const
SQLCollationCode getCollation () const
int getByteLength () const
int getMaxCharLength () const
void setNullable (bool nullable)

Detailed Description

Data types in the UDR interface.

Describes an SQL data type and the corresponding C/C++ type, used for scalar parameters, columns of input rows and columns of result rows.


Member Enumeration Documentation

Character sets

Enumerator:
CHARSET_ISO88591 

ISO 8859-1, single byte western European characters.

CHARSET_UTF8 

UTF-8, 1-4 byte Unicode encoding, length is in bytes.

CHARSET_UCS2 

UCS-2, 16 bit Unicode encoding, tolerates UTF-16.

Collations

Enumerator:
UNDEFINED_COLLATION 

undefined value

SYSTEM_COLLATION 

System collation, which is a binary collation, except that it ignores trailing blanks

Start and end fields of interval columns

Classes of types defined in the SQL standard

Enumerator:
CHARACTER_TYPE 

char and varchar types

NUMERIC_TYPE 

exact and approximate numerics

DATETIME_TYPE 

date/time/timestamp

INTERVAL_TYPE 

day/month or hour/second intervals

LOB_TYPE 

BLOBs and CLOBs.

UNDEFINED_TYPE_CLASS 

undefined value

SQL data types

Enumerator:
SMALLINT 

16 bit integer

INT 

32 bit integer

LARGEINT 

64 bit integer

NUMERIC 

Numeric with decimal precision.

DECIMAL_LSE 

Decimal, leading sign embedded.

SMALLINT_UNSIGNED 

unsigned 16 bit integer

INT_UNSIGNED 

unsigned 32 bit integer

NUMERIC_UNSIGNED 

unsigned numeric

DECIMAL_UNSIGNED 

unsigned decimal

REAL 

4 byte floating point number

DOUBLE_PRECISION 

8 byte floating point number

CHAR 

fixed length character types.

VARCHAR 

varying length character types.

DATE 

date

TIME 

time

TIMESTAMP 

timestamp

INTERVAL 

interval

BLOB 

Binary Large Object.

CLOB 

Character Large Object.

More detailed type information, but not as detailed as the actual type

Enumerator:
FIXED_CHAR_TYPE 

CHAR types.

VAR_CHAR_TYPE 

VARCHAR type.

EXACT_NUMERIC_TYPE 

Exact numeric.

APPROXIMATE_NUMERIC_TYPE 

Approximate numeric (floating point).

DATE_TYPE 

Date.

TIME_TYPE 

Time.

TIMESTAMP_TYPE 

Timestamp (date + time + optional fractional seconds)

YEAR_MONTH_INTERVAL_TYPE 

Intervals involving year and month.

DAY_SECOND_INTERVAL_TYPE 

Intervals involving days/hours/minutes/seconds

LOB_SUB_CLASS 

LOBs.

UNDEFINED_TYPE_SUB_CLASS 

undefined value


Constructor & Destructor Documentation

TypeInfo::TypeInfo ( const TypeInfo type  ) 

Copy constructor

TypeInfo::TypeInfo ( SQLTypeCode  sqlType = UNDEFINED_SQL_TYPE,
int  length = 0,
bool  nullable = false,
int  scale = 0,
SQLCharsetCode  charset = CHARSET_UTF8,
SQLIntervalCode  intervalCode = UNDEFINED_INTERVAL_CODE,
int  precision = 0,
SQLCollationCode  collation = SYSTEM_COLLATION 
)

Default constructor, with optional arguments

Construct a TypeInfo object from an SQL type, with several optional arguments (including the SQL type). This is mostly used to create formal parameters or output columns in the compiler interface, if a more complex data type is required that is not covered by the TupleInfo::addXXXColumn() methods.

Parameters:
sqlType SQL type enum to construct the type from.
length Length of CHAR/VARCHAR types, not needed for other types. Note that the length for UTF-8 types is in bytes, not characters, so this is equivalent to
[VAR]CHAR (length BYTES) CHARACTER SET UTF8
nullable Determines the NULL / NOT NULL attribute of the type Default: false (that means NOT NULL)
scale Scale for numeric type, fraction precision for fractional seconds, not needed for other types.
charset Character set enum for CHAR/VARCHAR types, not needed for other types.
intervalCode Interval code enum for intervals, not needed otherwise.
precision Precision for numeric types and leading precision for interval data types.
collation Collation enum for CHAR/VARCHAR types, not needed for other types. Note that only one type of collation is currently supported.
Exceptions:
UDRException 

Member Function Documentation

int TypeInfo::getByteLength (  )  const

Get the length of a value of the type.

Getting the length is useful for CHAR/VARCHAR data types but probably not as useful for other types that may have an internal representation unknown to a UDR writer. This returns the length in bytes, not in characters.

See also:
getCharLength()
Returns:
Length in bytes.
TypeInfo::SQLCharsetCode TypeInfo::getCharset (  )  const

Get the character set of the data type.

Returns:
Character set enum.
TypeInfo::SQLCollationCode TypeInfo::getCollation (  )  const

Get the collation for char/varchar data types.

Note that, currently, only one collation is supported. This default collation is a binary collation, except that trailing blanks are ignored.

Returns:
Collation enum.
TypeInfo::SQLIntervalCode TypeInfo::getIntervalCode (  )  const

Get the interval code for start/end fields.

Returns:
Interval code enum, indicating start and end fields of an interval type.
bool TypeInfo::getIsNullable (  )  const

Get whether the type is nullable.

Returns:
True for nullable types, false for non-nullable types.
int TypeInfo::getMaxCharLength (  )  const

Get the maximum number of characters that can be stored in this type.

This method should be used only for character types that have a fixed-width encoding. For variable-length encoding, like UTF-8, the method returns the highest possible number of characters (assuming single byte characters in the case of UTF-8). Right now, UTF-8 data types all have byte semantics, meaning there is no limit for the number of characters stored in a type, it is only limited by the number of bytes. The method returns 0 for numeric types. It returns the length of the string representation for types that are represented by a string, like datetime types.

See also:
getByteLength()
Returns:
Length in bytes.
Exceptions:
UDRException 
int TypeInfo::getPrecision (  )  const

Get the precision (max. number of significant digits).

The precision is the maximum number of digits before the decimal point a value can have. For interval types, this is the "leading precision". For example, an INTEGER value can range from -2,147,483,648 to 2,147,483,647. It's precision is 10, since the longest number has 10 digits. Note that not all 10 digit numbers can be represented in an integer. This is called binary precision. NUMERIC and DECIMAL types have decimal precision, meaning that a NUMERIC(10,0) type can represent values from -9,999,999,999 to +9,999,999,999.

Returns:
Precision of numeric types or interval types.
int TypeInfo::getScale (  )  const

Get the scale of the data type.

For integer, largeint, etc. types the scale is 0, since these are integer data types. For NUMERIC and DECIMAL types, a scale can be specified. Timestamp and some interval data types have a "fraction precision" value, which is the number of digits allowed after the decimal point for seconds. This fraction precision is returned as the scale, since can be considered the scale of the seconds part. For other data types like CHAR, the scale value is meaningless.

Returns:
Scale (digits after the decimal point) for numeric types, fraction precision (digits of fractional seconds) for intervals.
TypeInfo::SQLTypeCode TypeInfo::getSQLType (  )  const

Get the SQL type.

Returns:
SQL type enum.
TypeInfo::SQLTypeClassCode TypeInfo::getSQLTypeClass (  )  const

Get the SQL type class.

Determine whether this is a numeric character, datetime or interval type.

Returns:
SQL type class enum.
TypeInfo::SQLTypeSubClassCode TypeInfo::getSQLTypeSubClass (  )  const

Get the SQL type subclass.

This goes to one more level of detail beyond the type class, like exact/approximate numeric, char/varchar, etc.

Returns:
SQL type subclass enum.
void TypeInfo::setNullable ( bool  nullable  ) 

Set the nullable attribute of a type

Use this method to set types created locally in the UDF to be nullable or not nullable.

Parameters:
nullable true to set the type to nullable, false to give the type the NOT NULL attibute.

The documentation for this class was generated from the following files:
 All Data Structures Functions Enumerations Enumerator

Generated on 31 Aug 2016 for tmudr by  doxygen 1.6.1