更新日期:2024年09月11日
ifx_dececvt() 和 ifx_decfcvt() 函数是 dececvt() 和 decfcvt()GBase 8s ESQL/C 库函数
的线程安全版本。
语法
mint ifx_dececvt(np, ndigit, decpt, sign, decstr, decstrlen)
register dec_t *np;
register mint ndigit;
mint *decpt;
mint *sign;
char *decstr;
mint decstrlen;
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 701 -
mint ifx_decfcvt(np, ndigit, decpt, sign, decstr, decstrlen)
register dec_t *np;
register mint ndigit;
mint *decpt;
mint *sign;
char *decstr;
mint decstrlen;
np
指向包含要被转换的 decimal 值的 decimal 结构的指针。
ndigit
ifx_dececvt() 的 ASCII 字符串的长度。它是 ifx_decfcvt() 的小数点的右边的位数。
decpt
指向整数的指针,该整数是小数点相对于该字符串的开头的位置。*decpt 的负值或零
值意味着该位置位于返回的数字的左边。
sign
指向结果的符号的指针。如果该结果的符号为负的,则 *sign 非零;否则,它为零。
decstr
函数将转换了的 decimal 值返回到其中的用户定义的缓冲区。
decstrlen
用户定义的 decstr 缓冲区的长度,以字节计。
用法
ifx_dececvt() 函数是 dececvt() 函数的线程安全版本。ifx_decfcvt() 函数是 decfcvt()
函数的线程安全版本。当两个线程同时调用该函数时,每一函数返回一个不可被重写的字
符串。
返回代码
0
转换成功。
<0
转换不成功。
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 702 -
-1273
输出缓冲区为空,或太小以至于不能保存结果。
rstol() 函数将以空终止的字符串转换为 long integer 值。
语法
mint rstol(string, long_int)
char *string;
mlong *long_int;
string
指向以空终止的字符串的指针。
long_int
指向保存转换了的值的 mlong 值的指针。
用法
值的合法范围为 -2,147,483,647 - 2,147,483,647。值 -2,147,483,648 不是有效的,因为
此值为指示空的保留值。
返回代码
=0
转换成功。
!=0
转换失败。
示例
此样例程序在 demo 目录中的 rstol.ec 文件中。
/*
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 904 -
* rstol.ec *
The following program tries to convert three strings to longs. It displays the result of each
attempt.
*/
#include
EXEC SQL include sqltypes;
main()
{
mint err;
mlong l;
printf("RSTOL Sample ESQL Program running.\n\n");
l = 0;
printf("Converting String 'abc':\n");
if((err = rstol("abc", &l)) == 0)
printf("\tResult = %ld\n\n", l);
else
printf("\tError %d in conversion of string #1\n\n", err);
l = 0;
printf("Converting String '2147483646':\n");
if((err = rstol("2147483646", &l)) == 0)
printf("\tResult = %ld\n\n", l);
else
printf("\tError %d in conversion of string #2\n\n", err);
l = 0;
printf("Converting String '':\n");
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 905 -
if((err = rstol("", &l)) == 0)
{
if(risnull(CLONGTYPE, (char *) &l))
printf("\tResult = NULL\n\n", l);
else
printf("\tResult = %ld\n\n", l);
}
else
printf("\tError %d in conversion of string #3\n\n", err);
printf("\nRSTOL Sample Program over.\n\n");
}
输出
RSTOL Sample ESQL Program running.
Converting String 'abc':
Error -1213 in conversion of string #1
Converting String '2147483646':
Result = 2147483646
Converting String '':
Result = NULL
RSTOL Sample Program over.