返回首页

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

更新日期:2024年09月11日

资源库备份...................................... 114

执行一个SQL 语句并返回影响的行数。

语法
[Visual Basic]
Public Overrides Function ExecuteNonQuery As Integer
[C#]
public override int ExecuteNonQuery()

返回值
影响的行数。

实现



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

- 139 -
IDbCommand.ExecuteNonQuery()

注释
用户可以使用ExecuteNonQuery 来执行任何类型的数据库操作,这时,任
何返回结果集都不可用。任何用于存储过程的参数可以用于绑定数据而且在执
行后可以返回完整的结果。对于UPDATE, INSERT, 和 DELETE 语句,返回值是
命令影响的行数。对于其它类型的语句,返回值是-1。

示例
下面的例子创建了一个GBaseCommand 并使用ExecuteNonQuery 来执行它。
例子的参数是要执行的SQL 语句(例如UPDATE, INSERT, or DELETE)和用于连
接数据源的字符串。
[Visual Basic]
Public Sub CreateGBaseCommand(gsExecuteQuery As String,_
gsConnection_
As GBaseConnection)
Dim gsCommand As New GBaseCommand (gsExecuteQuery_
,gsConnection)
gsCommand.Connection.Open()
gsCommand.ExecuteNonQuery()
gsConnection.Close()
End Sub

[C#]
public void CreateGBaseCommand(string gsExecuteQuery,
GBaseConnection gsConnection)
{
GBaseCommand gsCommand =New GBaseCommand (gsExecuteQuery,
gsConnection);
gsCommand.Connection.Open();
gsCommand.ExecuteNonQuery();
gsConnection.Close();
}

GBase 8a 程序员手册ADO.NET 篇


- 140 -

南大通用数据技术股份有限公司

ifx_int8cvdbl() 函数将 C double 类型数值转换为 int8 类型数值。
语法
mint ifx_int8cvdbl(dbl_val, int8_val)
double dbl_val;
ifx_int8_t *int8_val;
dbl_val
ifx_int8cvdbl() 将其转换为 int8 类型值的 double 值。
int8_val
指向 ifx_int8cvdbl() 放置转换结果处的 int8 结构的指针。

返回代码
0
转换成功。
<0
转换失败。

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


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

The following program converts two double type numbers to
INT8 types and displays the results.
*/

#include

EXEC SQL include "int8.h";

char result[41];

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

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

printf("Number 1 (double) = 1234.5678901234\n");
if (x = ifx_int8cvdbl((double)1234.5678901234, #))
{
printf("Error %d in converting double1 to INT8\n", x);
exit(1);
}
if (x = ifx_int8toasc(#, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String Value = %s\n", result);
/* notice that the ifx_int8cvdbl function truncates digits to the right of a decimal separator.
*/

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


printf("Number 2 (double) = %.1f\n", d);
if (x = ifx_int8cvdbl(d, #))
{
printf("Error %d in converting double2 to INT8\n", x);
exit(1);
}
if (x = ifx_int8toasc(#, result, sizeof(result)))
{
printf("Error %d in converting second INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String Value = %s\n", result);

printf("\nIFX_INT8CVDBL Sample Program over.\n\n");
exit(0);
}
输出

IFX_INT8CVDBL Sample ESQL Program running.

Number 1 (double) = 1234.5678901234
String Value = 1234
Number 2 (double) = 2147483647.0
String Value = 2147483647
IFX_INT8CVDBL Sample Program over.\