[yunqa.de] Re: DISQLite and Variants

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sat, 04 Oct 2008 15:12:52 +0200

Nicklas Bergfeldt wrote:

>I managed to solve it on my own using the following:
>
>Bind_Variant(
>         Bind_Parameter_Index16(':MyParamName'),
>         Variable
>       );

Yes, you can make this a descendant of TDISQLite3Statement or apply some simple 
changes to DISQLite3Database.pas (sources are in the \Source folder):

procedure TDISQLite3Statement.Bind_Variant_By_Name(const AParamName: 
AnsiString; const AValue: Variant);
begin
  CheckActive;
  Check(sqlite3_bind_variant(FHandle, bind_Parameter_Index(AParamName), 
AValue));
end;

procedure TDISQLite3Statement.Bind_Variant_By_Name16(const AParamName: 
WideString; const AValue: Variant);
begin
  CheckActive;
  Check(sqlite3_bind_variant(FHandle, sqlite3_bind_parameter_index(FHandle, 
PAnsiChar(sqlite3_encode_utf8(AParamName))), AValue));
end;

>function GetVariant(const Stmt: TDISQLite3Statement; const Index: integer): 
>Variant;
>begin
> case Stmt.Column_Type(Index) of
>   SQLITE_INTEGER: Result := Stmt.Column_Int64(Index);
>   SQLITE_FLOAT:   Result := Stmt.Column_Double(Index);
>   SQLITE_TEXT:    Result := Stmt.Column_Str16(Index);
>   SQLITE_BLOB:    Result := Null;
>   SQLITE_NULL:    Result := Null;
> end;
>end;

Please know that this function does not properly map certain variant types. See 
my answer to your previous message for details.

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: