返回首页

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

更新日期:2024年09月11日

PG_STAT_XACT_SYS_TABLES 视图显示命名空间中系统表的事务状态信息。
名称
类型
描述

GBase 8c V5 开发者手册
南大通用数据技术股份有限公司
907
名称
类型
描述
relid
oid
表的OID。
schemaname
name
该表的模式名。
relname
name
表名。
seq_scan
bigint
该表发起的顺序扫描数。
seq_tup_read
bigint
顺序扫描抓取的活跃行数。
idx_scan
bigint
该表发起的索引扫描数。
idx_tup_fetch
bigint
索引扫描抓取的活跃行数。
n_tup_ins
bigint
插入行数。
n_tup_upd
bigint
更新行数。
n_tup_del
bigint
删除行数。
n_tup_hot_upd
bigint
HOT 更新行数(比如没有更新所需的单独索引)。

下表指明了驱动如何映射本地服务器数据类型到默认的SQL 和C 数据类型:

本地值
SQL 类型
C 类型
bit
SQL_BIT
SQL_C_BIT
tinyint
SQL_TINYINT
SQL_C_STINYINT
tinyint unsigned SQL_TINYINT
SQL_C_UTINYINT
bigint
SQL_BIGINT
SQL_C_SBIGINT
bigint unsigned
SQL_BIGINT
SQL_C_UBIGINT
long varbinary
SQL_LONGVARBINARY
SQL_C_BINARY
blob
SQL_LONGVARBINARY
SQL_C_BINARY
longblob
SQL_LONGVARBINARY
SQL_C_BINARY
tinyblob
SQL_LONGVARBINARY
SQL_C_BINARY
mediumblob
SQL_LONGVARBINARY
SQL_C_BINARY
long varchar
SQL_LONGVARCHAR
SQL_C_CHAR
text
SQL_LONGVARCHAR
SQL_C_CHAR
mediumtext
SQL_LONGVARCHAR
SQL_C_CHAR
char
SQL_CHAR
SQL_C_CHAR
numeric
SQL_NUMERIC
SQL_C_CHAR
decimal
SQL_DECIMAL
SQL_C_CHAR
integer
SQL_INTEGER
SQL_C_SLONG
integer unsigned SQL_INTEGER
SQL_C_ULONG
int
SQL_INTEGER
SQL_C_SLONG
int unsigned
SQL_INTEGER
SQL_C_ULONG
mediumint
SQL_INTEGER
SQL_C_SLONG
mediumint
unsigned
SQL_INTEGER
SQL_C_ULONG
smallint
SQL_SMALLINT
SQL_C_SSHORT
smallint
unsigned
SQL_SMALLINT
SQL_C_USHORT

GBase 8a 程序员手册ODBC 篇


- 44 -

南大通用数据技术股份有限公司
本地值
SQL 类型
C 类型
real
SQL_FLOAT
SQL_C_DOUBLE
double
SQL_FLOAT
SQL_C_DOUBLE
float
SQL_REAL
SQL_C_FLOAT
double precision SQL_DOUBLE
SQL_C_DOUBLE
date
SQL_DATE
SQL_C_DATE
time
SQL_TIME
SQL_C_TIME
year
SQL_SMALLINT
SQL_C_SHORT
datetime
SQL_TIMESTAMP
SQL_C_TIMESTAMP
timestamp
SQL_TIMESTAMP
SQL_C_TIMESTAMP
longtext
SQL_LONGVARCHAR
SQL_C_CHAR
tinytext
SQL_LONGVARCHAR
SQL_C_CHAR
varchar
SQL_VARCHAR
SQL_C_CHAR
enum
SQL_VARCHAR
SQL_C_CHAR
set
SQL_VARCHAR
SQL_C_CHAR
bit
SQL_CHAR
SQL_C_CHAR
bool
SQL_CHAR
SQL_C_CHAR

rsetnull() 函数将 C 变量设置为对应于数据库空值的值。

语法
mint rsetnull(type, ptrvar)
mint type;

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

char *ptrvar;
type
对应于 C 或 GBase 8s ESQL/C 变量的数据类型的 mint。此 type 可为除
了 var binary 或 lvarchar 指针变量之外的任何数据类型。
ptrvar
指向 C 或 GBase 8s ESQL/C 变量的指针。

用法

rsetnull() 函数将除了 var
binary 和 lvarchar 指针主变量之外的任何
数据类型的 GBase
8s
ESQL/C 变量设置为空。
要将 var
binary 或 lvarchar 指
针主变量设置为空,请使用 ifx_var_setnull() 宏。

示例
此样例程序在 demo 目录中的 rsetnull.ec 文件中。
/*
* rsetnull.ec *

This program fetches rows from the stock table for a chosen manufacturer and allows the
user to set the unit_price to NULL.
*/

#include
#include
EXEC SQL include decimal;
EXEC SQL include sqltypes;

#define WARNNOTIFY 1
#define NOWARNNOTIFY 0

#define LCASE(c) (isupper(c) ? tolower(c) : (c))

char format[] = "($$,$$$,$$$.&&)";

main()

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

{
char decdsply[20];
char ans;
int4 ret, exp_chk();

EXEC SQL BEGIN DECLARE SECTION;
short stock_num;
char description[16];
dec_t unit_price;
char manu_code[4];
EXEC SQL END DECLARE SECTION;

printf("RSETNULL Sample ESQL Program running.\n\n");
EXEC SQL connect to 'stores7'; /* connect to stores7 */
exp_chk("Connect to stores7", NOWARNNOTIFY);

printf("This program selects all rows for a given manufacturer\n");
printf("from the stock table and allows you to set the unit_price\n");
printf("\nTo begin, enter a manufacturer code - for example: 'HSK'\n");
printf("\nEnter Manufacturer code: ");
/* prompt for mfr. code */
gets(manu_code); /* get mfr. code */
EXEC SQL declare upcurs cursor for /* declare cursor */
select stock_num, description, unit_price from stock
where manu_code = :manu_code
for update of unit_price;
rupshift(manu_code); /* Make mfr code upper case */
EXEC SQL open upcurs; /* open select cursor */
if(exp_chk("Open cursor", WARNNOTIFY) == 1)
exit(1);

/*
* Display Column Headings

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

*/
printf("\nStock # \tDescription \t\tUnit Price");
while(1)
{
/* get a row */
EXEC SQL fetch upcurs into :stock_num, :description, :unit_price;
if ((ret = exp_chk("fetch", WARNNOTIFY)) == 100)
/* if end of rows */
break;
if(ret == 1)
exit(1);
if(risnull(CDECIMALTYPE, (char *) &unit_price))
/* unit_price NULL? */
continue; /* skip to next row */
rfmtdec(&unit_price, format, decdsply);
/* format unit_price */
/* display item */
printf("\n\t%d\t%15s\t%s", stock_num, description, decdsply);
ans = ' ';
/* Set unit_price to NULL? y(es) or n(o) */
while((ans = LCASE(ans)) != 'y' && ans != 'n')
{
printf("\n. . . Set unit_price to NULL ? (y/n) ");
scanf("%1s", &ans);
}
if (ans == 'y') /* if yes, NULL to unit_price */
{
rsetnull(CDECIMALTYPE, (char *) &unit_price);
EXEC SQL update stock set unit_price = :unit_price
where current of upcurs; /* and update current row */
if(exp_chk("UPDATE", WARNNOTIFY) == 1)
exit(1);
}

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

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

/*
* The exp_chk() file contains the exception handling functions to check the
SQLSTATE status variable to see if an error has occurred following an SQL statement. If a
warning or an error has occurred, exp_chk() executes the GET DIAGNOSTICS statement and
prints the detail for each exception that is returned.
*/

EXEC SQL include exp_chk.ec

输出
RSETNULL Sample ESQL Program running.

This program selects all rows for a given manufacturer
from the stock table and allows you to set the unit_price
to NULL.

To begin, enter a manufacturer code - for example: 'HSK'

Enter Manufacturer code: HSK

Stock # Description Unit Price
1 baseball gloves $800.00
. . . Set unit_price to NULL ? (y/n) n

3 baseball bat $240.00
. . . Set unit_price to NULL ? (y/n) y

4 football $960.00
. . . Set unit_price to NULL ? (y/n) n

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


110 helmet $600.00
. . . Set unit_price to NULL ? (y/n) y

RSETNULL Sample Program over.