返回首页

gbase数据、南大通用产品文档:GBase8sha set timeout 参数:更改 SD 辅助服务器超时(SQL 管理 API)

更新日期:2024年09月11日

............. - 750 -

当传递给 rleapyear() 函数的是闰年时,它返回 1(TRUE),当不是时,它返回 0
(FALSE)。

语法
mint rleapyear(year)
mint year;
year
整数。

用法
参数 year 必须是日期的年份组件,而不是该日期本身。您必须必须以完整的形式
(2007),而不是缩写的形式(07)来表达 year。

返回代码
1
该年份为闰年。
0
该年份不是闰年。
示例

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 890 -
demo 目录在 rleapyear.ec 文件中包含此样例程序。
/*
* rleapyear.ec *

The following program accepts a date entered from the console and stores this date into an
int4, which stores the date in an internal format. It then converts the internal format into an array
of three short integers that contain the month, day, and year portions of the date. It then tests the
year value to see if the year is a leap year.
*/

#include

main()
{
int4 i_date;
mint errnum;
short mdy_array[3];
char date[20];
mint x;

static char fmtstr[9] = "mmddyyyy";

printf("RLEAPYEAR Sample Program running.\n\n");

/* Allow user to enter a date */
printf("Enter a date as a single string, month.day.year\n");
gets(date);

printf("\nThe date string is %s.\n", date);

/* Put entered date in internal format */
if (x = rdefmtdate(&i_date, fmtstr, date))
printf("Error %d on rdefmtdate conversion\n", x);
else

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

/* Convert internal format into a MDY array */
if ((errnum = rjulmdy(i_date, mdy_array)) == 0)
{
/* Check if it is a leap year */
if (rleapyear(mdy_array[2]))
printf("%d is a leap year\n", mdy_array[2]);
else
printf("%d is not a leap year\n", mdy_array[2]);
}
else
printf("rjulmdy() call failed with error %d", errnum);
}

printf("\nRLEAPYEAR Sample Program over.\n\n");
}
输出
RLEAPYEAR Sample ESQL Program running.

Enter a date as a single string, month.day.year
10.12.07

The date string is 10.12.07.
2007 is not a leap year

RLEAPYEAR Sample Program over.

invextend() 函数复制不同限定符之下的 interval 值。

扩展是添加或删除 INTERVAL 值的字段的操作,来使得它与给定的限定符相匹配。
对于 INTERVAL 值,两个限定符都必须属于同一 interval 类:或者 year to month 类,
或者 day to fraction(5) 类。

语法
mint invextend(in_inv, out_inv)
intrvl_t *in_inv, *out_inv;
in_inv
指向要扩展的 interval 变量的指针。
out_inv
指向带有有效的限定符用于扩展的 interval 变量的指针。

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

用法
invextend() 函数将 in_invinterval 变量的限定符字段数字复制至 out_inv interval 变
量。out_inv 变量的限定符控制该复制。

该函数丢弃 in_inv 中最低有效字段右边的 out_inv 中的任何字段。该函数填写未出
现在 in_inv 中的 out_inv 中的任何字段,如下:
它以零填充 in_inv 中最低有效字段右边的字段。
它将 in_inv 中最高有效字段左边的字段设置为有效的 interval 值。

返回代码
0
转换成功。
<0
转换失败。
-1266
interval 值与该操作不兼容。
-1268
参数包含无效的 interval 限定符。



示例
demo 目录在文件 invextend.ec 中包含此样例程序。该示例程序说明 interval 扩展。
在第二个结果中,在 seconds 字段中,输出包含零,且已将 days 字段设置为 3。
/*
* invextend.ec *

The following program illustrates INTERVAL extension. It extends an INTERVAL value
to another INTERVAL value with a different qualifier. Note that in the second example, the
output contains zeros in the seconds field and the days field has been set to 3.
*/


GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 843 -
#include
EXEC SQL include datetime;

main()
{
mint x;
char out_str[16];
;
EXEC SQL BEGIN DECLARE SECTION;
interval hour to minute hrtomin;
interval hour to hour hrtohr;
interval day to second daytosec;
EXEC SQL END DECLARE SECTION;

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

printf("Interval (hour to minute) value = 75.27\n");
incvasc("75:27", &hrtomin);

/* Extend to hour-to-hour and convert the internal format to
* ascii for displaying
*/
invextend(&hrtomin, &hrtohr);
intoasc(&hrtohr, out_str);
printf("Extended (hour to hour) value = %s\n", out_str);

/* Extend to day-to-second and convert the internal format to ascii for displaying
*/
invextend(&hrtomin, &daytosec);
intoasc(&daytosec, out_str);
printf("Extended (day to second) value =: %s\n", out_str);

printf("\nINVEXTEND Sample Program over.\n\n");

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

输出
INVEXTEND Sample ESQL Program running.

Interval (hour to minute) value = 75:27
Extended (hour to hour) value = 75
Extended (day to second) value = 3 03:27:00
INVEXTEND Sample Program over.