mORMot and Open Source friends
Check-in [6699709798]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added TSQLRequest.FieldDeclaredType() method and associated TSQLRequest.FieldDeclaredTypeS() method
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6699709798603183a5d9200e719e56517ac057c9
User & Date: ab 2013-01-05 11:08:12
Context
2013-01-05
11:45
fixed 64 bit compilation issue check-in: dd9d230ff3 user: ab tags: trunk
11:08
added TSQLRequest.FieldDeclaredType() method and associated TSQLRequest.FieldDeclaredTypeS() method check-in: 6699709798 user: ab tags: trunk
2013-01-04
18:53
updated documentation about DDD check-in: ff4c50e532 user: abouchez tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynSQLite3.pas.

126
127
128
129
130
131
132

133
134
135
136
137
138
139
140
....
1934
1935
1936
1937
1938
1939
1940









1941
1942
1943
1944
1945
1946
1947
....
4714
4715
4716
4717
4718
4719
4720


















4721
4722
4723
4724
4725
4726
4727
  - fixed ticket [8dc4d49ea9] in TSQLDataBase.GetFieldNames()about result array
    truncated to 64

  Version 1.18
  - updated SQLite3 engine to version 3.7.15.1
  - raise an ESQLite3Exception if DBOpen method is called twice
  - TSQLDataBase.DBClose returns now the sqlite3_close() status code

  - added TSQLRequest.BindS() and TSQLRequest.FieldS() methods for direct
    string process
  - added TSQLDatabase.LogResultMaximumSize property to reduce logged extend

    Todo:
    - port to systems other than Delphi+Win32 (use external DLL?)
}

................................................................................
    function FieldBlobToStream(Col: integer): TStream;
    {/ return TRUE if the column value is NULL, first Col is 0 }
    function FieldNull(Col: Integer): Boolean;
    {/ return the field type of this column
     - retrieve the "SQLite3" column type as returned by sqlite3_column_type -
       i.e. SQLITE_NULL, SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, or SQLITE_BLOB  }
    function FieldType(Col: Integer): integer;









    {/ append all columns values of the current Row to a JSON stream
     - will use WR.Expand to guess the expected output format
     - BLOB field value is saved as Base64, in the '"\uFFF0base64encodedbinary"
       format and contains true BLOB data }
    procedure FieldsToJSON(WR: TJSONWriter);
    {/ the column/field count of the current ROW
     - fields numerotation starts with 0 }
................................................................................

function TSQLRequest.FieldType(Col: Integer): integer;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  result := sqlite3_column_type(Request,Col);
end;



















function TSQLRequest.FieldUTF8(Col: integer): RawUTF8;
var P: PUTF8Char;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  P := pointer(sqlite3_column_text(Request,Col));






>
|







 







>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
....
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
....
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
  - fixed ticket [8dc4d49ea9] in TSQLDataBase.GetFieldNames()about result array
    truncated to 64

  Version 1.18
  - updated SQLite3 engine to version 3.7.15.1
  - raise an ESQLite3Exception if DBOpen method is called twice
  - TSQLDataBase.DBClose returns now the sqlite3_close() status code
  - added TSQLRequest.FieldDeclaredType() method
  - added TSQLRequest.BindS()/FieldS()/FieldDeclaredTypeS() methods for direct
    string process
  - added TSQLDatabase.LogResultMaximumSize property to reduce logged extend

    Todo:
    - port to systems other than Delphi+Win32 (use external DLL?)
}

................................................................................
    function FieldBlobToStream(Col: integer): TStream;
    {/ return TRUE if the column value is NULL, first Col is 0 }
    function FieldNull(Col: Integer): Boolean;
    {/ return the field type of this column
     - retrieve the "SQLite3" column type as returned by sqlite3_column_type -
       i.e. SQLITE_NULL, SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, or SQLITE_BLOB  }
    function FieldType(Col: Integer): integer;
    {/ return the type of this column, as declared at creation
     - textual type used for CREATE TABLE of the corresponding column, as
       returned by sqlite3_column_decltype()  }
    function FieldDeclaredType(Col: Integer): RawUTF8;
    {/ return the generic VCL string type of this column, as declared at creation
     - textual type used for CREATE TABLE of corresponding column, as
       returned by sqlite3_column_decltype()
     - note that prior to Delphi 2009, you may loose content during conversion }
    function FieldDeclaredTypeS(Col: Integer): string;
    {/ append all columns values of the current Row to a JSON stream
     - will use WR.Expand to guess the expected output format
     - BLOB field value is saved as Base64, in the '"\uFFF0base64encodedbinary"
       format and contains true BLOB data }
    procedure FieldsToJSON(WR: TJSONWriter);
    {/ the column/field count of the current ROW
     - fields numerotation starts with 0 }
................................................................................

function TSQLRequest.FieldType(Col: Integer): integer;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  result := sqlite3_column_type(Request,Col);
end;

function TSQLRequest.FieldDeclaredType(Col: Integer): RawUTF8;
var P: PUTF8Char;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  P := pointer(sqlite3_column_decltype(Request,Col));
  SetString(result,P,SynCommons.StrLen(P));
end;

function TSQLRequest.FieldDeclaredTypeS(Col: Integer): String;
var P: PUTF8Char;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  P := pointer(sqlite3_column_decltype(Request,Col));
  result := UTF8DecodeToString(P,SynCommons.StrLen(P));
end;

function TSQLRequest.FieldUTF8(Col: integer): RawUTF8;
var P: PUTF8Char;
begin
  if cardinal(Col)>=cardinal(FieldCount) then
    raise ESQLite3Exception.Create(RequestDB, SQLITE_RANGE);
  P := pointer(sqlite3_column_text(Request,Col));