ESQL/C的数据类型
1、SQL与C数据类型的对应
简单类型
SQL C
CHAR(n) char(n+1)
CHARCTER(n) char *
SMALLINT short int
INTERGER
INT long int
SMALLFLOAT
REAL float
FLOAT
DOUBLE PRECISIONdouble
SERIAL long int
DATE long int
复杂类型
SQL C
DECIMAL
DEC NUMERIC dec_t or struct decimal
MONEY dec_t or struct decimal
DATETIME dtime_t or struct dtime
INREVER intrvl_t or struct intrvl
VARCHAR varchar or string
2、数据类型转换
转换类型 转换后
FLOAT DECIMAL(16)
SMALLFLOAT DECIMAL(8)
INTERGER DECIMAL(10,0)
SAMLLINT DECIMAL(5,0)
二、数据类型的转换函数
(一)有关CHAR类型的函数
1、以空值结尾的串的操作函数
rdownshift(char *s) 把一个字符串中的所有字母转换成小写形式。
rupshift(char *s) 把一个字符串中的所有字母转换成大写形式。
stcat(char *s, char *dest) 把一个字符串同另一个字符串相连接。
stcmpr(char *s1, char *s2) 比较两个字符串。
stcopy(char *from, char *to) 把一个字符串拷贝到另一个字符串。
stleng(char *string) 统计字符串的长度。
2、定长串的操作函数
bycmpr(char byte1, byte2, rpt len) 比较两组连续的字节内存块。
bycopy(char *from, char *to, int len) 把一块内存的内容拷贝到另一块内存。
byfill(char *to, int len, char ch) 用字符填充指定的内存块。
byleng(char from, int count) 统计有效字符的数目。有效字符是指字符串去除了末尾空格所剩的字符。
3、字符串操作函数
ldchar(char *from, int num, char *to) 拷贝定长串到空值结尾的串。
stchar(char *from, char *to, int num) 拷贝空值结尾的串到定长串。
4、字符串函数简单数值转换
rstod(char *str, double *dblval) 把以空值结束的字符串转