返回首页

gbase数据、南大通用产品文档:GBase8srstrdate() 函数

更新日期:2024年09月11日

rstrdate() 函数将字符串转换为内部的 DATE。

语法
mint rstrdate(inbuf, jdate)
char *inbuf;
int4 *jdate;
inbuf

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

指向包含要转换的日期的字符串的指针。
jdate
指向接收 inbuf 字符串的内部 DATE 值的 int4 整数的指针。

用法

对于缺省的语言环境 US English, rstrdate() 函数以下列优先顺序来确定如何格式化
该字符串:
DBDATE 环境变量指定的格式(如果设置 DBDATE 的话)。
GL_DATE 环境变量指定的格式(如果设置 GL_DATE 的话)。
缺省的日期形式:mm/dd/yyyy。您可使用任何非数值的字符作为月份、日子与年份之
间的分隔符。您可将年份表达为四位数字(2007),或为两位数值(07)。

当您使用非缺省的语言环境,
且未设置 DBDATE 或 GL_DATE 环境变量时,
rstrdate()
使用客户机语言环境定义的日期终端用户格式。

当您在日期字符串中使用两位数字年份时,
rstrdate() 函数使用 DBCENTURY 环境变
量的值来确定要使用哪个世纪。
如果您未设置 DBCENTURY,
则 rstrdate() 为两位年份假
定第 20 世纪。
返回代码
0
转换成功。
< 0
转换失败。
-1204
inbuf 参数指定无效的年份。
-1205
inbuf 参数指定无效的月份。
-1206
inbuf 参数指定无效的日子。
-1212
数据转换格式必须包含月份、日子或年份组件。DBDATE 指定数据转换格式。

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

-1218
由 inbuf 参数指定的日期未正确地表示日期。

示例
demo 目录在 rstrdate.ec 文件中包含此样例程序。
/*
* rstrdate.ec *
The following program converts a character string
in "mmddyyyy" format to an internal date format.
*/

#include

main()
{
int4 i_date;
mint errnum;
char str_date[15];

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

/* Convert Sept. 6th, 2007 into i_date */
if ((errnum = rstrdate("9.6.2007", &i_date)) == 0)
{

rfmtdate(i_date, "mmm dd yyyy", str_date);
printf("Date '%s' converted to internal format\n" str_date);
}
else
printf("rstrdate() call failed with error %d\n", errnum);

printf("\nRSTRDATE Sample Program over.\n\n");
}

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

输出

RSTRDATE Sample ESQL Program running.

Date 'Sep 06 2007' converted to internal format

RSTRDATE Sample Program over.

功能说明
使用交互模式或者命令方式运行backup level [0 | 1],即可完成数据备份。进行备份
操作时,必须保证集群在READONLY 模式下。
首先使用gcadmin switchmode readonly 命令将集群置为READONLY 模式,此命令
仅在一个部署gcware 的节点上执行一次即可。

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
382
执行完毕后,启动集群备份命令,即可进行备份操作了。
语法格式
backup level < 0 | 1 >
示例
步骤1:查看集群状态:
$ gcadmin
CLUSTER STATE:
ACTIVE
===========================================================
=====
|
GBASE COORDINATOR CLUSTER INFORMATION
|
===========================================================
=====
|
NodeName
|
IpAddress
| gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | 172.168.83.11 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
| coordinator2 | 172.168.83.12 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
| coordinator3 | 172.168.83.13 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
===========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|
===========================================================
|
VcName
| DistributionId |
comment
|
-----------------------------------------------------------
|
vc1
|
1
| comment message for vc1 |
-----------------------------------------------------------
|
vc2
|
2
| comment message for vc2 |
-----------------------------------------------------------
2 virtual cluster: vc1, vc2
3 coordinator node
0 free data node
$ gcadmin showcluster vc vc1
CLUSTER STATE:
ACTIVE
VIRTUAL CLUSTER MODE:
NORMAL
==========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
383
==========================================================
|
VcName
| DistributionId |
comment
|
----------------------------------------------------------
|
vc1
|
1
| comment message for vc1 |
----------------------------------------------------------
===========================================================
=======
|
VIRTUAL CLUSTER DATA NODE INFORMATION
|
===========================================================
=======
|NodeName|
IpAddress
|DistributionId|gnode|syncserver|DataState|
------------------------------------------------------------------
| node1
|172.168.83.11|
1
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
| node2
|172.168.83.12|
1
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
2 data node
$ gcadmin showcluster vc vc2
CLUSTER STATE:
ACTIVE
VIRTUAL CLUSTER MODE:
NORMAL
==========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|
==========================================================
|
VcName
| DistributionId |
comment
|
----------------------------------------------------------
|
vc2
|
2
| comment message for vc2 |
----------------------------------------------------------
===========================================================
=======
|
VIRTUAL CLUSTER DATA NODE INFORMATION
|
===========================================================
=======
|NodeName|
IpAddress
|DistributionId|gnode|syncserver|DataState|
------------------------------------------------------------------
| node1
|172.168.83.13|
2
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
| node2
|172.168.83.14|
2
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
384
2 data node
步骤2:设置集群内所有vc 的状态为readonly:
$ gcadmin switchmode readonly vc vc1
========== switch cluster mode...
switch pre mode:
[NORMAL]
switch mode to
[READONLY]
switch after mode:
[READONLY]
$ gcadmin switchmode readonly vc vc2
========== switch cluster mode...
switch pre mode:
[NORMAL]
switch mode to
[READONLY]
switch after mode:
[READONLY]
$ gcadmin
CLUSTER STATE:
ACTIVE
===========================================================
=====
|
GBASE COORDINATOR CLUSTER INFORMATION
|
===========================================================
=====
|
NodeName
|
IpAddress
| gcware | gcluster | DataState |
----------------------------------------------------------------
| coordinator1 | 172.168.83.11 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
| coordinator2 | 172.168.83.12 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
| coordinator3 | 172.168.83.13 |
OPEN
|
OPEN
|
0
|
----------------------------------------------------------------
===========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|
===========================================================
|
VcName
| DistributionId |
comment
|
-----------------------------------------------------------
|
vc1
|
1
| comment message for vc1 |
-----------------------------------------------------------
|
vc2
|
2
| comment message for vc2 |
-----------------------------------------------------------
2 virtual cluster: vc1, vc2
3 coordinator node
0 free data node

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
385
$ gcadmin showcluster vc vc1
CLUSTER STATE:
ACTIVE
VIRTUAL CLUSTER MODE:
READONLY
==========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|
==========================================================
|
VcName
| DistributionId |
comment
|
----------------------------------------------------------
|
vc1
|
1
| comment message for vc1 |
----------------------------------------------------------
===========================================================
=======
|
VIRTUAL CLUSTER DATA NODE INFORMATION
|
===========================================================
=======
|NodeName|
IpAddress
|DistributionId|gnode|syncserver|DataState|
------------------------------------------------------------------
| node1
|172.168.83.11|
1
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
| node2
|172.168.83.12|
1
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
2 data node
$ gcadmin showcluster vc vc2
CLUSTER STATE:
ACTIVE
VIRTUAL CLUSTER MODE:
READONLY
===========================================================
|
GBASE VIRTUAL CLUSTER INFORMATION
|
===========================================================
|
VcName
| DistributionId |
comment
|
-----------------------------------------------------------
|
vc2
|
2
| comment message for vc2 |
-----------------------------------------------------------
===========================================================
=======
|
VIRTUAL CLUSTER DATA NODE INFORMATION
|
===========================================================
=======

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
386
|NodeName|
IpAddress
|DistributionId|gnode|syncserver|DataState|
------------------------------------------------------------------
| node1
|172.168.83.13|
2
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
| node2
|172.168.83.14|
2
|OPEN |
OPEN
|
0
|
------------------------------------------------------------------
2 data node
使用交互模式进行全备:
$ python $GCLUSTER_BASE/server/bin/gcrcman.py -d /home/gbase/backup -P
gbasedba –p ******
gcrcman>backup level 0

游标的属性用于控制程序流程或者了解程序的状态。当运行DML 语句时,PL/SQL 打
开一个内建游标并处理结果,游标是维护查询结果的内存中的一个区域,游标在运行DML
语句时打开,完成后关闭。显式游标的属性为:

%FOUND 布尔型属性:当最近一次读记录时成功返回,则值为TRUE。

%NOTFOUND 布尔型属性:与%FOUND 相反。

%ISOPEN 布尔型属性:当游标已打开时返回TRUE。

%ROWCOUNT 数值型属性:返回已从游标中读取的记录数。