Example:
With qrytemp do begin
If active then close;
SQL. Clear;
// Select dsjbh, Qh, uphone, zjtype, uzjsj, checkflag from user_card
SQL. Text: = 'Update user_card set checkflag = 1 where'
+ 'Dsjbh =: dsjbh and uphone =: Phone and QH =: qh ';
Parameters. parambyname ('dsjbh '). Value: = dsjbh;
Parameters. parambyname ('phone'). Value: = uphone;
Parameters. parambyname ('qh'). Value: = QH;
Execsql;
Another example:
With qrypx do begin
Close; // select
SQL. Clear;
SQL. text: = 'select top 30 dsjbh, qh, zjtype, uphone, uzjsj, checkflag from user_card'
+ 'Where uzjsj> =: uzjsj and checkflag = 0 order by uzjsj, uphone ';
Parameters. ParamByName ('uzjsj '). Value: = lastzjtime;
Open;
If recordcount> 0 then begin
While not eof do begin
Application. ProcessMessages ();
Sleep (1 );
If (bExitFlag) then break;
Strqh: = trim (Fieldbyname ('qh'). AsString );
Strphone: = trim (Fieldbyname ('uphone'). AsString );
Strdsjbh: = trim (Fieldbyname ('dsjbh '). AsString );
StrZjtype: = trim (Fieldbyname ('zjtype'). AsString); // Add the installation type
Zjtime: = Fieldbyname ('uzjsj '). AsDateTime;
Example 3:
Try
With QryTemp do begin
If Active then close;
SQL. Clear;
SQL. Text: = 'select mkbh from haomaduan'
+ 'Where dsjbh = ''' + strdsjbh + ''' and qh = ''' + strqh
+ ''' And (cast (starthao as bigint) <= '+ strphone +
') And (cast (endhao as bigint)> =' + strphone + '))';
Open;
If recordcount> 0 then result: = trim (fieldbyname ('mkbh '). asstring)
Else result: = '-1'
End;
Except
Result: = '-1 ';
End;