返回首页

gbase数据、南大通用产品文档:GBase8s

更新日期:2024年09月11日

Proxy Error: No database connection
如果您尝试使用一个无效或坏的数据库连接与数据库通信,则 GBase 8s HTTP Proxy 会抛
出此错误。
请确保您的应用程序已经打开到数据库的连接,检查您的网络服务器和数据库错误日志。

ifx_int8toasc() 函数将 int8 类型数值转换为 C char 类型值。
语法

mint ifx_int8toasc(int8_val, strng_val, len)
ifx_int8_t *int8_val;

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 747 -

char *strng_val;
mint len;
int8_val
指向 ifx_int8toasc() 将其值转换为文本字符串的 int8 结构的指针。
strng_val
指向 ifx_int8toasc() 放置文本字符串处的字符缓冲区的第一个字节的指针。
len
以字节计算的 strng_val 的大小,对于空终止符,为负 1。
用法
如果 int8 数值不适于放入长度 len 的字符串内,则 ifx_int8toasc() 将该数值转换为
指数计数法。如果该值仍不适合,则 ifx_int8toasc() 以星号填充字符串。 如果该数值比字
符串短,则 ifx_int8toasc() 向左对齐该数值,并用空格填充它的右边。
由于 ifx_int8toasc() 返回的字符串不是以空终止的,因此,在您打印它之前,您必须
将空字符添加到该字符串。
当您使用非缺省的语言环境(US English 之外的一种)时,ifx_int8toasc() 支持
strng_val 字符串中的非 ASCII 字符。要获取更多信息,
返回代码
0
转换成功。
-1207
被转换的值不适于放入分配了的空间内。
示例
demo 目录中的文件 int8toasc.ec 包含下列样例程序。
/*
* ifx_int8toasc.ec *

The following program converts three string
constants to INT8 types and then uses ifx_int8toasc()
to convert the INT8 values to C char type values.
*/

#include
#define END sizeof(result)

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 748 -


EXEC SQL include "int8.h";

char string1[] = "-12,555,444,333,786,456";
char string2[] = "480";
char string3[] = "5.2";
char result[40];

main()
{
mint x;
ifx_int8_t num1, num2, num3;

printf("IFX_INT8tOASC Sample ESQL Program running.\n\n");

if (x = ifx_int8cvasc(string1, strlen(string1), &num1))
{
printf("Error %d in converting string1 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string2, strlen(string2), &num2))
{
printf("Error %d in converting string2 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string3, strlen(string3), &num3))
{
printf("Error %d in converting string3 to INT8\n", x);
exit(1);
}
printf("\nConverting INT8 back to ASCII\n");
printf(" Executing: ifx_int8toasc(&num1, result, END - 1)");
if (x = ifx_int8toasc(&num1, result, END - 1))

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 749 -

printf("\tError %d in converting INT8 to string\n", x);
else
{
result[END - 1] = '\0'; /* null terminate */
printf("\n The value of the first INT8 is = %s\n", result);
}
printf("\nConverting second INT8 back to ASCII\n");
printf(" Executing: ifx_int8toasc(&num2, result, END - 1)");
if (x= ifx_int8toasc(&num2, result, END - 1))
printf("\tError %d in converting INT8 to string\n", x);
else
{
result[END - 1] = '\0'; /* null terminate */
printf("\n The value of the 2nd INT8 is = %s\n", result);
}

printf("\nConverting third INT8 back to ASCII\n");
printf(" Executing: ifx_int8toasc(&num3, result, END - 1)");
/* note that the decimal is truncated */

if (x= ifx_int8toasc(&num3, result, END - 1))
printf("\tError %d in converting INT8 to string\n", x);
else
{
result[END - 1] = '\0'; /* null terminate */
printf("\n The value of the 3rd INT8 is = %s\n", result);
}
printf("\nIFX_INT8tOASC Sample Program over.\n\n");
exit(0);
}
输出

IFX_INT8tOASC Sample ESQL Program running.

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 750 -



Converting INT8 back to ASCII
Executing: ifx_int8toasc(&num1, result, sizeof(result)-1)
The value of the first INT8 is = -12555444333786456

Converting second INT8 back to ASCII
Executing: ifx_int8toasc(&num2, result, sizeof(result)-1)
The value of the 2nd INT8 is = 480

Converting third INT8 back to ASCII
Executing: ifx_int8toasc(&num3, result, END)
The value of the 3rd INT8 is = 5

cognos 使用odbc 驱动连接数据库问题
问题现象
cognos 使用odbc 驱动连接数据库,执行语句报错Out of memory 和Segmentation
fault。在使用cognos 刷新cube 的时候,进程因“段错误”异常终止,查看刷新
日志、cognos server 日志、transfomer 工具调用日志皆无异常(故判断与cognos
无关),后查看了linux 服务器运行日志,发现报了个驱动的错误。
SQL> call p1();
Out of memory (Needed 4171804 bytes)
[ISQL]ERROR: Could not SQLExecute
Out of memory (Needed 4171804 bytes)
Out of memory (Needed 4171804 bytes)
message 日志里面
Nov 5 15:11:23 PSTFILE kernel: isql[7263]: segfault at f30f8010 ip
00000000004d3c05 sp 00000000ffb55d80 error 6 in
libgsodbc8-8.3.so[494000+1aa000]
解决方法:
使用了32bit 的odbc 驱动,32bit 程序最多只能使用4G 内存,但是结果集大于4G
导致保存out of memory。建议使用no_cache 参数,在odbc.ini 中增加参数
no_cache=1,不再宕机,但性能会大幅下降。