SQL code operations in Delphi

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.