版次注意事項


35.7 Chapter 20. Programming in C and C++

The following table supplements the information included in chapter 7, "Stored Procedures", chapter 15, "Writing User-Defined Functions and Methods", and chapter 20, "Programming in C and C++". The table lists the supported mappings between SQL data types and C data types for stored procedures, UDFs, and methods.

35.7.1 C/C++ Types for Stored Procedures, Functions, and Methods


Table 22. SQL Data Types Mapped to C/C++ Declarations
SQL Column Type C/C++ Data Type SQL Column Type Description
SMALLINT
(500 or 501)
sqlint16 16-bit signed integer
INTEGER
(496 or 497)
sqlint32 32-bit signed integer
BIGINT
(492 or 493)
sqlint64 64-bit signed integer
REAL
(480 or 481)
float Single-precision floating point
DOUBLE
(480 or 481)
double Double-precision floating point
DECIMAL(p,s)
(484 or 485)
Not supported.

To pass a decimal value, define the parameter to be of a data type castable from DECIMAL (for example CHAR or DOUBLE) and explicitly cast the argument to this type.

CHAR(n)
(452 or 453)
char[n+1] where n is large enough to hold the data


1<=n<=254

Fixed-length, null-terminated character string
CHAR(n) FOR BIT DATA
(452 or 453)
char[n+1] where n is large enough to hold the data


1<=n<=254

Fixed-length character string
VARCHAR(n)
(448 or 449) (460 or 461)
char[n+1] where n is large enough to hold the data


1<=n<=32 672

Null-terminated varying length string
VARCHAR(n) FOR BIT DATA
(448 or 449)
struct {
  sqluint16 length;
  char[n]
}
 
1<=n<=32 672
Not null-terminated varying length character string
LONG VARCHAR
(456 or 457)
struct {
  sqluint16 length;
  char[n]
}
 
32 673<=n<=32 700
Not null-terminated varying length character string
CLOB(n)
(408 or 409)
struct {
  sqluint32 length;
  char data[n];
}
 
1<=n<=2 147 483 647
Non null-terminated varying length character string with 4-byte string length indicator
BLOB(n)
(404 or 405)
struct {
  sqluint32 length;
  char data[n];
}
 
1<=n<=2 147 483 647
Non null-terminated varying binary string with 4-byte string length indicator
DATE
(384 or 385)
char[11] null-terminated character form
TIME
(388 or 389)
char[9] null-terminated character form
TIMESTAMP
(392 or 393)
char[27] null-terminated character form
Note:
The following data types are only available in the DBCS or EUC environment when precompiled with the WCHARTYPE NOCONVERT option.
GRAPHIC(n)
(468 or 469)
sqldbchar[n+1] where n is large enough to hold the data


1<=n<=127

Fixed-length, null-terminated double-byte character string
VARGRAPHIC(n)
(400 or 401)
sqldbchar[n+1] where n is large enough to hold the data


1<=n<=16 336

Not null-terminated, variable-length double-byte character string
LONG VARGRAPHIC
(472 or 473)
struct {
  sqluint16 length;
  sqldbchar[n]
}
 
16 337<=n<=16 350
Not null-terminated, variable-length double-byte character string
DBCLOB(n)
(412 or 413)
struct {
  sqluint32 length;
  sqldbchar data[n];
}
 
1<=n<=1 073 741 823
Non null-terminated varying length character string with 4-byte string length indicator


[ 頁面頂端 | 前一頁 | 下一頁 | 目錄 | 索引 ]