16,748
社区成员
发帖
与我相关
我的任务
分享
function GetSql(ssql, v_Param: string): variant; // 函数GetSql ssql, v_Param字符串参数 返回值variant类型
// ssql 是SQLygqk
// v_Param 是带入的SQL的参数值
var
Q: ToraQuery; // 声明Q 为ToraQuery控件
s: tstringlist; // 声明S 为TStringlist
i: Integer; // 声明i integer 可以删除
begin
s := tstringlist.Create; // 创建 S TStringlist
s.Clear; // tstringlist 清空
Q := ToraQuery.Create(nil); // 创建 Q ToraQuery;
Q.Session := MainForm.OraSession1; // Q指定 OraSession1
OpenQuery(Q, ssql); // 为Q指定SQL SSQL是SQL语句
SetParam(Q, V_Param); // 为Q指定参数 V_Param是参数的变量
Q.Open; // 打开Q
if Q.IsEmpty then // 如果Q数据集为空
Result := '' // 返回空
else // 否则
Result := Q.Fields[0].Value; // 返回打开表的第一个字段的值
if VarIsNull(result) then // 如果返回值 Null
begin
result := ''; // 返回空
end;
Q.Close; // 关闭Q
Q.Free; // 释放Q
end;