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.
  • 相关阅读:
    操作数据库插入,更新中文信息出现乱码
    ServletResponse使用介绍
    Tomcat乱码问题
    ServletRequest使用介绍
    Servlet的生命周期
    方法重写与方法重载的区别
    Java异常ClassCastException
    异常java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
    CentOS7通过源码安装nginx
    LDA与PCA
  • 原文地址:https://www.cnblogs.com/del88/p/7397171.html
Copyright © 2011-2022 走看看