返回首页

gbase数据、南大通用产品文档:GBase8s配置数据库服务器

更新日期:2024年09月11日

在将客户机应用程序连接到数据库服务器之前,请先配置数据库服务器环境。
有关更多信息,请参阅《UNIX™ 和 Linux™ 平台 GBase
8s 安装指南》或《GBase
8s 管
理员指南》。

理 API)
随同 admin() 或 task() 函数,使用 modify config 参数来更改内存中配置参数的值,
直到您重启数据库服务器。使用 modify config persistent 参数来更改内存中配置参数
的值并在您重启服务器之后在 onconfig 文件中保存该值。
语法

表 1. modify config 命令元素
元素
描述
关键考虑
configuration_parameter_name
您想要更改的配置
参数的名称。

new_value
配置参数的新值。 要了解关于配置参数的有效值信

GBase 8s 管理员参考
南大通用数据技术股份有限公司 - 753 -

元素
描述
关键考虑
息,请参阅 数据库配置参数。

用法
这个 SQL 管理 API 命令等用于使用 onmode -wm 或 -wf 命令来更改配置参数的值。
示例
下列命令为当前使用将内存中的 DYNAMIC_LOGS 配置参数的值更改为 2:
EXECUTE FUNCTION task("modify config","DYNAMIC_LOGS","2");
下列命令为当前使用更改 DYNAMIC_LOGS 配置参数的值。在您重启服务器之后,更改的值
保留在 onconfig 文件中。
EXECUTE FUNCTION task("modify config persistent","DYNAMIC_LOGS","2");

dececvt() 和 decfcvt() 函数相似,对于“UNIX(TM) 程序员手册”的第三部分中
ECVT(3) 之下的子例程。dececvt() 函数的工作方式与 ecvt(3) 函数相同,decfcvt() 函数的
工作方式与 fcvt(3) 函数相同。它们都将 decimal 类型数值转换为 C char 类型值。

语法
char *dececvt(dec_val, ndigit, decpt, sign)
dec_t *dec_val;
mint ndigit;
mint *decpt;
mint *sign;

char *decfcvt(dec_val, ndigit, decpt, sign)
dec_t *dec_val;
mint ndigit;
mint *decpt;

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

mint *sign;
dec_val
指向包含您想要这些函数来转换的 decimal 值的 decimal 结构的指针。
ndigit
dececvt() 的 ASCII 字符串的长度。它是 decfcvt() 的小数点右边的数字的数目。
decpt
指向一个整数的指针,该整数是小数点相对于字符串起点的位置。*decpt 的负值或零
意味着在返回的数字的左边。
sign
指向结果的符号的指针。 如果结果的符号为负,则 *sign 非零;否则,*sign 为零。


用法

dececvt() 函数将 np 指向的 decimal 值转换为 ndigit ASCII 数字的以空结尾的字符
串,并返回指向该字符串的指针。对此函数的后续调用重写该字符串。

dececvt() 函数对低位数字四舍五入。

decfcvt() 函数与 dececvt() 相同,除了 ndigit 指定小数点右边的数字的数目,而不是
数字的总数目之外。

让 dec_val 指向 12345.67 的 decimal 值,并阻止除了 ndigit 之外的所有参数。对
于四个不同的 ndigit 值,下表展示 dececvt() 函数返回的值。

ndigit 值
返回字符串
*decpt 值
*sign
4
"1235"
5
0
10
"1234567000"
5
0
1
"1"
5
0
3
"123"
5
0

要获取 dec_val 和 ndigit 值的更多示例,请参阅 dececvt() 的示例上
dececvt.ec 演示程序的样例输出。

重要:
当您编写线程安全 GBase
8s
ESQL/C 应用程序时,
请不要使用 dececvt()

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

或 decfcvt() 库函数。
反而,
请使用它们的线程安全等价的 ifx_dececvt() 和
ifx_decfcvt() 函数。

dececvt() 的示例

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

The following program converts a series of DECIMAL numbers to fixedm strings of 20
ASCII digits. For each conversion it displays the resulting string, the decimal position from
the beginning of the string and the sign value.
*/

#include

EXEC SQL include decimal;


char *strings[] =
{
"210203.204",
"4894",
"443.334899312",
"-12344455",
"12345.67",
".001234",
0
};

char result[40];

main()
{

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

mint x;
mint i = 0, f, sign;
dec_t num;
char *dp, *dececvt();

printf("DECECVT Sample ESQL Program running.\n\n");
while(strings[i])
{
if (x = deccvasc(strings[i], strlen(strings[i]), #))
{
printf("Error %d in converting string [%s] to DECIMAL\n",x, strings[i]);
break;
}
printf("\Input string[%d]: %s\n", i, strings[i]);

/* to 20-char ASCII string */

dp = dececvt(#, 20, &f, &sign);
printf(" Output of dececvt(#, 20, ...): %c%s decpt: %d sign: %d\n",
(sign ? '-' : '+'), dp, f, sign);

/* display result */

/* to 10-char ASCII string */

dp = dececvt(#, 10, &f, &sign);
printf(" Output of dececvt(#, 10, ...): %c%s decpt: %d sign: %d\n",(sign ? '-' : '+'),
dp, f, sign);

/* to 4-char ASCII string */

dp = dececvt(#, 4, &f, &sign);


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

/* display result */
printf(" Output of dececvt(#, 4, ...): %c%s decpt: %d
sign: %d\n",(sign ? '-' : '+'), dp, f, sign);

/* to 3-char ASCII string */
dp = dececvt(#, 3, &f, &sign);

/* display result */
printf(" Output of dececvt(#, 3, ...): %c%s decpt: %d sign: %d\n", (sign ? '-' : '+'),
dp, f, sign);

/* to 1-char ASCII string */
dp = dececvt(#, 1, &f, &sign);

/* display result */
printf(" Output of dececvt(#, 1, ...): %c%s decpt:
%d sign: %d\n",(sign ? '-' : '+'), dp, f, sign);

++i; /* next string */
}
printf("\nDECECVT Sample Program over.\n\n");
}
dececvt() 的输出
DECECVT Sample ESQL Program running.

Input string[0]: 210203.204
Output of dececvt: +2102 decpt: 6 sign: 0
Output of dececvt: +2102032040 decpt: 6 sign: 0
Output of dececvt: +2 decpt: 6 sign: 0
Output of dececvt: +210 decpt: 6 sign: 0

Input string[1]: 4894
Output of dececvt: +4894 decpt: 4 sign: 0

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

Output of dececvt: +4894000000 decpt: 4 sign: 0
Output of dececvt: +5 decpt: 4 sign: 0
Output of dececvt: +489 decpt: 4 sign: 0

Input string[2]: 443.334899312
Output of dececvt: +4433 decpt: 3 sign: 0
Output of dececvt: +4433348993 decpt: 3 sign: 0
Output of dececvt: +4 decpt: 3 sign: 0
Output of dececvt: +443 decpt: 3 sign: 0

Input string[3]: -12344455
Output of dececvt: -1234 decpt: 8 sign: 1
Output of dececvt: -1234445500 decpt: 8 sign: 1
Output of dececvt: -1 decpt: 8 sign: 1
Output of dececvt: -123 decpt: 8 sign: 1

Input string[4]: 12345.67
Output of dececvt: +1235 decpt: 5 sign: 0
Output of dececvt: +1234567000 decpt: 5 sign: 0
Output of dececvt: +1 decpt: 5 sign: 0
Output of dececvt: +123 decpt: 5 sign: 0

Input string[5]: .001234
Output of dececvt: +1234 decpt: -2 sign: 0
Output of dececvt: +1234000000 decpt: -2 sign: 0
Output of dececvt: +1 decpt: -2 sign: 0
Output of dececvt: +123 decpt: -2 sign: 0

DECECVT Sample Program over.

decfcvt() 的示例

demo 目录中的文件 decfcvt.ec 包含下列示例程序。

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

/*
* decfcvt.ec *
The following program converts a series of DECIMAL numbers to strings of ASCII
digits with 3 digits to the right of the decimal point. For each conversion it displays the
resulting string, the position of the decimal point from the beginning of the string and the sign
value. */

#include

EXEC SQL include decimal;

char *strings[] =
{
"210203.204",
"4894",
"443.334899312",
"-12344455",
0
};

main()
{
mint x;
dec_t num;
mint i = 0, f, sign;
char *dp, *decfcvt();

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

while(strings[i])
{
if (x = deccvasc(strings[i], strlen(strings[i]), #))
{
printf("Error %d in converting string [%s] to DECIMAL\n", x, strings[i]);

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

break;
}

dp = decfcvt(#, 3, &f, &sign); /* to ASCII string */

/* display result */
printf("Input string[%d]: %s\n", i, strings[i]);
printf(" Output of decfcvt: %c%*.*s.%s decpt: %d sign: %d\n\n", (sign ?
'-' : '+'), f, f, dp, dp+f, f, sign);
++i; /* next string */
}
printf("\nDECFCVT Sample Program over.\n\n");
}
decfcvt() 的输出

DECFCVT Sample ESQL Program running.

Input string[0]: 210203.204
Output of decfcvt: +210203.204 decpt: 6 sign: 0

Input string[1]: 4894
Output of decfcvt: +4894.000 decpt: 4 sign: 0

Input string[2]: 443.334899312
Output of decfcvt: +443.335 decpt: 3 sign: 0

Input string[3]: -12344455
Output of decfcvt: -12344455.000 decpt: 8 sign: 1
DECFCVT Sample Program over.