返回首页

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

更新日期:2024年09月11日


示例

demo 目录中的文件 dectrunc.ec 包含下列样例程序。
/*
* dectrunc.ec *

The following program truncates a DECIMAL number six times and displays each result.
*/

#include

EXEC SQL include decimal;

char string[] = "-12345.038572";
char result[41];

main()
{
mint x;
mint i = 6; /* number of decimal places to start with */
dec_t num1;

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

printf("String = %s\n", string);
while(i)

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 670 -
{
if (x = deccvasc(string, strlen(string), &num1))
{
printf("Error %d in converting string to DECIMAL\n", x);
break;
}
dectrunc(&num1, i);
if (x = dectoasc(&num1, result, sizeof(result), -1))
{
printf("Error %d in converting result to string\n", x);
break;
}
result[40] = '\0';
printf("Truncated to %d Fractional Digits: %s\n", i--, result);
}

printf("\nDECTRUNC Sample Program over.\n\n");
}
输出

DECTRUNC Sample ESQL Program running.

String = -12345.038572
Truncated to 6 Fractional Digits: -12345.038572
Truncated to 5 Fractional Digits: -12345.03857
Truncated to 4 Fractional Digits: -12345.0385
Truncated to 3 Fractional Digits: -12345.038
Truncated to 2 Fractional Digits: -12345.03
Truncated to 1 Fractional Digits: -12345.0

DECTRUNC Sample Program over.

SDK 和 GBase 8s Connect

设置 GBASEDBTCPPMAP 环境变量以指定 C++ 程序的映射文件的全限定路径名。
映射文
件中的信息包括数据库服务器类型、支持该数据库对象或值对象类型的共享库的名称、该
对象的库入口点以及对其构建对象的 C++ 库。

pathname 存储 C++ 映射文件的目录路径。
该映射文件是可具有任何文件名的文本文件。
您可以指定数个映射文件,
在 UNIX™ 上
用冒号 ( : ) 分隔。
在 UNIX 上,缺省映射文件为 $GBASEDBTDIR/etc/c++map。