#1 2010-07-23 09:53:52

longge007
Member
Registered: 2010-06-22
Posts: 107

how to query one row based on time Field

Sir, how to find Message based on time  like this

 Rec := TSQLSampleRecord.Create(Database,'Name="%"',[StringToUTF8(NameEdit.Text)]);

and in Sqlite3, can you write one Query Options based one time Colfield ,i haven't found any files about this.
like this,One is statand SQL option, another is delphi query option

 select * from Samplerecord where time....

thanks a lot,

Last edited by longge007 (2010-07-23 09:56:04)

Offline

#2 2010-07-23 10:27:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: how to query one row based on time Field

for executing a SQL statement

select * from Samplerecord where time....

you must use TSQLRestClient.List, defined as such:

  TSQLRestClient = class(TSQLRest)
  public
    /// retrieve a list of members as a TSQLTable (implements REST GET Collection)
    // - default SQL statement is 'SELECT ID FROM TableName;' (i.e. retrieve
    // the list of all ID of this collection members)
    // - optional SQLSelect parameter to change the returned fields
    // as in 'SELECT SQLSelect FROM TableName;'
    // - optional SQLWhere parameter to change the search range or ORDER
    // as in 'SELECT SQLSelect FROM TableName WHERE SQLWhere;'
    function List(const Tables: array of TClass; const SQLSelect: RawUTF8 = 'ID';
      const SQLWhere: RawUTF8 = ''): TSQLTableJSON; virtual; abstract;

So you'll code for example:

var J: TSQLTableJSON;
  i, FieldIndex: integer;
(...)
  J := Client.List([TSQLSampleRecord],'*','Time='+Int32ToUtf8(TimeValue));
  if J<>nil then
  try
    FieldIndex := J.FieldIndex('Name');
    if FieldIndex>=0 then
      for i := 1 to J.RowCount do
        ListBox.Add(UTF8ToString(J.GetU(i,FieldIndex)));
  finally
    J.Free;
  end;

Offline

#3 2010-07-23 10:47:20

longge007
Member
Registered: 2010-06-22
Posts: 107

Re: how to query one row based on time Field

if my Datetime is 2010-07-22 18:44:52:532,in fact it's double

the Int32ToUft8() only can get Int value,

how to transfer,thanks a lot

Offline

Board footer

Powered by FluxBB