zoukankan      html  css  js  c++  java
  • LiteQuery MAX(Integer)、MAX(String) 判断是否返回值

    unit Unit6;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, LiteCall, LiteConsts, Vcl.StdCtrls,
      Data.DB, MemDS, DBAccess, LiteAccess;
    
    type
      TForm6 = class(TForm)
        LiteConnection1: TLiteConnection;
        LiteQuery1: TLiteQuery;
        Button1: TButton;
        LiteQuery2: TLiteQuery;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form6: TForm6;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm6.Button1Click(Sender: TObject);
    begin
      LiteQuery1.Close;
      LiteQuery1.SQL.Text := 'SELECT MAX(age) AS max_age FROM max_test';
      LiteQuery1.Open;
      if LiteQuery1.IsEmpty then
      begin
        ShowMessage('IsEmpty');
      end else begin
        ShowMessage('非空');
        ShowMessage(LiteQuery1.FieldByName('max_age').AsString);
        if LiteQuery1.FieldByName('max_age').IsNull then
        begin
          ShowMessage('为null');
        end else begin
          ShowMessage(LiteQuery1.FieldByName('max_age').AsString);
        end;
      end;
    end;
    
    procedure TForm6.Button2Click(Sender: TObject);
    begin
      LiteQuery2.Close;
      LiteQuery2.SQL.Text := 'SELECT MAX(name) AS max_name FROM max_test';
      LiteQuery2.Open;
      if LiteQuery2.IsEmpty then
      begin
        ShowMessage('IsEmpty');
      end else begin
        ShowMessage('非空');
        ShowMessage(LiteQuery2.FieldByName('max_name').AsString);
        if LiteQuery2.FieldByName('max_name').IsNull then
        begin
          ShowMessage('为null');
        end else begin
          ShowMessage(LiteQuery2.FieldByName('max_name').AsString);
        end;
    
    
      end;
    end;
    
    end.
  • 相关阅读:
    Jenkins+ansible+Gitlab集成环境搭建
    Jenkins 和常用工具集成
    Jenkins 安装部署及应用
    ansible 及相关应用
    gitlab 快速安装
    [持续交付实践] 交付流水线设计:基于测试脚本的线上拨测监控系统
    gitlab CICD
    Nginx判断UserAgent添加referer
    Nginx判断变量的配置
    golang 入门之环境搭建
  • 原文地址:https://www.cnblogs.com/del88/p/7397171.html
Copyright © 2011-2022 走看看