返回首页

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

更新日期:2024年09月11日




(String,
String,
GBaseParameter[])
对GBase 数据库执行一句SQL 命令,方法执行期间,一个新的
GBaseConnection 对象会被创建、打开和关闭。通过GBaseParameter[]参数传
递命令对象使用的参数。

语法
[Visual Basic]
Public Shared Function ExecuteReader ( _

connectionString As String, _

commandText As String, _

ParamArray commandParameters As GBaseParameter() _
) As GBaseDataReader
[C#]
public static GBaseDataReader ExecuteReader(

string connectionString,

string commandText,



GBase 8a 程序员手册ADO.NET 篇
南大通用数据技术股份有限公司

- 267 -

params GBaseParameter[] commandParameters
)

参数
1) connectionString :用于创建GBaseConnection 对象的连接字符串;

2) commandText :要执行的SQL 语句;
3) commandParameters :用于GBaseCommand 对象的参数数组。


返回值
准备读取命令结果的GBaseDataReader 对象。

说明
SHA 脱敏对字符列起作用,对列内容应用SHA 算法处理。
示例

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
457
gbase> CREATE TABLE t_m_sha(context VARCHAR(255) MASKED WITH(FUNCTION
= 'SHA()'));
Query OK, 0 rows affected (Elapsed: 00:00:00.08)
gbase> INSERT INTO t_m_sha VALUES('abc');
Query OK, 1 row affected (Elapsed: 00:00:00.10)
gbase> SELECT * FROM t_m_sha;
+------------------------------------------+
| context
|
+------------------------------------------+
| a9993e364706816aba3e25717850c26c9cd0d89d |
+------------------------------------------+
1 row in set (Elapsed: 00:00:00.03)
表4- 79 脱敏前数据
内容(varchar(255))
abc
表4- 80 应用SHA 脱敏后显示结果
内容(varchar(255))
“a9993e364706816aba3e25717850c26c9cd0d89d”
注意
NULL 值不做脱敏处理,仍显示为NULL。

deccvdbl() 函数将 C double 类型数值转换为 decimal 类型数值。
语法
mint deccvdbl(dbl_val, np)
double dbl_val;
dec_t *dec_val;
dbl_val
deccvdbl() 转换为 decimal 类型值的 double 值。
dec_val
指向 deccvdbl() 在其中放置转换结果的 decimal 结构的指针。

结果代码

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

0
转换成功。
<0
转换失败。

示例

demo 目录中的 deccvdbl.ec 文件包含下列样例程序。
/*
* deccvdbl.ec *
The following program converts two double type numbers to DECIMAL numbers and
displays the results.
*/

#include

EXEC SQL include decimal;

char result[41];


main()
{
mint x;
dec_t num;
double d = 2147483647;

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

printf("Number 1 (double) = 1234.5678901234\n");
if (x = deccvdbl((double)1234.5678901234, #))
{
printf("Error %d in converting double1 to DECIMAL\n", x);

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

exit(1);
}
if (x = dectoasc(#, result, sizeof(result), -1))
{
printf("Error %d in converting DECIMAL1 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String Value = %s\n", result);

printf("Number 2 (double) = $.1f\n", d);
if (x = deccvdbl(d, #))
{
printf("Error %d in converting double2 to DECIMAL\n", x);
exit(1);
}
if (x = dectoasc(#, result, sizeof(result), -1))
{
printf("Error %d in converting DECIMAL2 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String Value = %s\n", result);

printf("\nDECCVDBL Sample Program over.\n\n");
exit(0);
}
输出
DECCVDBL Sample ESQL Program running.

Number 1 (double) = 1234.5678901234
String Value = 1234.5678901234
Number 2 (double) = 2147483647.0

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

String Value = 2147483647.0
DECCVDBL Sample Program over.