一、获取数据:
1.方式一
with cdsStaff do
begin
Close;
Params.Clear;
with Params.CreateParam(ftString, 'i_numcode', ptInput) do
AsString := trim(edtNumcode.Text);
with Params.CreateParam(ftString, 'i_psw', ptInput) do
AsString := dmpub.PswEcyt(trim(edtPasswd.Text));
strSql := 'SELECT * FROM STAFF WHERE NUMCODE = :i_numcode AND PSW = :i_psw and nvl(IsWas,0) = 0';//lye 120106增加非废码条件
Data := dmPub.GetData(strSql, Params);
Open;
end;
2.方式二
with cdsTmp do
begin
CommandText :=
' select p.* ' +
' from MatPriceAdjPN p ' +
' where p.State=:State ' +
' order by billid ';
Params.ParamByName('State').AsInteger := C_BILL_CONFIRMED;
Params.ParamByName('BillDate').AsDateTime := dmPub.GetRemoteTime;
Params.ParamByName('DepID').AsInteger := CurStf.DepID;
data := dmPub.GetData(CommandText, Params, false);
end;
二、执行SQL语句:
1.方式一:
cdsTmp : TwwClientDataSet;
cdsTmp := TwwClientDataSet.Create(self);
with cdsTmp do
begin
Commandtext :=
' UPDATE MATAPLP ' +
' SET OPID = :OPID ' +
' WHERE BILLID = :BILLID ';
Params.ParamByName('OPID').AsInteger := fBillID;
Params.ParamByName('BILLID').AsInteger := cdsBillBillID.Value;
dmpub.ExecSQL(Commandtext,Params,o_result);
end;
2.方式二:
with cdsSysParam do
begin
strSQL := 'UPDATE SYSPARAM SET VALUE = :i_Value WHERE UPPER(PRMCODE) = :i_Prmcode';
Close;
Params.Clear;
with Params.CreateParam(ftString, ':i_Value', ptInput) do
AsString := InttoStr(WrValue);
with Params.CreateParam(ftString, ':i_Prmcode', ptInput) do
AsString := UpperCase(PrmCode);
if ExecSQL(strSQL, Params, oResult) then
Result := True
else
UtilsPub.MsgDlg('写系统参数表错误!' + oResult, mtInformation);
end;
三、运行储存过程:
1.方式一:
with dmPub.cdsStpPub do
begin
Params.Clear;
//设置参数
with Params.CreateParam(ftInteger, 'i_actstf', ptInputOutput) do
AsInteger := Actcon.ActStf;
with Params.CreateParam(ftString, 'i_actcode', ptInputOutput) do
AsString := Actcon.ActCode;
with Params.CreateParam(ftInteger, 'i_bedid', ptInputOutput) do
AsInteger := Actcon.ActBedID;
with Params.CreateParam(ftInteger, 'i_PatId', ptInputOutput) do
AsInteger := Actcon.ActPatID;
with Params.CreateParam(ftInteger, 'i_clinid', ptInputOutput) do
AsInteger := Actcon.ActClinID;
with Params.CreateParam(ftString, 'i_dspt', ptInputOutput) do
AsString := Actcon.ActDec;
//调用函数语句
if not dmPub.RunProcedure('GenActLog', Params, oResult) then
begin
UtilsPub.MsgDlg(VartoStr(oResult),mtInformation);
Result := False;
end
else
Result := True;
end;
2.方式二:
Params := TParams.Create(nil);
try
Params.CreateParam(ftInteger, 'i_BillIDA', ptInput).AsInteger := cdsParentBill.FieldByName('BillID').AsInteger;
Params.CreateParam(ftInteger, 'i_BillIDB', ptInput).AsInteger := cdsTmp.FieldByName('BillId').AsInteger;
Params.CreateParam(ftString, 'o_Result', ptOutput);
if not dmPub.RunProcedure('dsTwoMtBillIsEqu', Params, o_Result) then
begin
UtilsPub.MsgDlg(vartostr(o_Result), mtInformation, [MBOK]);
Abort;
end;
finally
Params.Free;
end;
3.方式三:
var
vResult:String;
oResult: OleVariant;
Param: TParams;
begin
inherited;
Param := TParams.Create(nil);
Param.CreateParam(ftInteger, 'i_StfId', ptInput);
Param.CreateParam(ftInteger, 'i_ID', ptInput);
Param.CreateParam(ftInteger, 'i_BNo', ptInput);
Param.CreateParam(ftString, 'o_Result', ptOutput);
Param.ParamByName('i_StfId').AsInteger := CurStf.StfID;
Param.ParamByName('i_ID').AsInteger := FID;
Param.ParamByName('i_BNo').AsString := edtBNOS.Text;
if not dmPub.RunProcedure('brPrintBNo', Param, oResult) then
begin
edtBNOS.SetFocus;
edtBNOS.SelectAll;
UtilsPub.MsgDlg(VartoStr(oResult), mtError,[mbOk]);
end;
Param.Free;
ModalResult := mrOk;
end;
四、更新数据
1.方式一
sResult: string;
if not dmpub.UpdateData(cdsTmp, sResult) then
utilspub.MsgDlg(sResult, mtError);