LiteQuery MAX(Integer)MAX(String) 判断是否返回值

Posted 不能富贵难成大器皆因懒, 胸无大志庸庸碌碌只为闲。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.

 

以上是关于LiteQuery MAX(Integer)MAX(String) 判断是否返回值的主要内容,如果未能解决你的问题,请参考以下文章

为啥 FileChannel.map 占用了 Integer.MAX_VALUE 的数据?

Number.MAX_SAFE_INTEGER 在 32 位计算机中的值为 (2^53 - 1) [重复]

Integer.MAX_VALUE和Integer.MIN_VALUE的解释,用于查找数组中的最小值和最大值

如何在火花中处理 Integer.MAX_VALUE? [关闭]

为啥 Number.MAX_SAFE_INTEGER 是 9,007,199,254,740,991 而不是 9,007,199,254,740,992?

Spark Java 错误:大小超过 Integer.MAX_VALUE