Subject | Re: inserting blobs more than 16kb |
---|---|
Author | Eduardo A. Salgado |
Post date | 2007-03-19T21:38:29Z |
--- In firebird-support@yahoogroups.com, jesus martinez
<jesus_martinez1967@...> wrote:
Delphi, we have no problem with size and something like:
function TdmFBDatabase.SaveBlobToDatabase(TableName, KeyFieldName,
BlobFieldName: string; KeyID: variant; Blob: TStream;
ATransName: string = DefaultTrans): integer;
var Stream: TStringStream;
begin
Result := 0;
Stream := TStringStream.Create ('');
Stream.CopyFrom (Blob, 0);
try
qryBlobManager.SQL.Text := 'update '+TableName+' set '+
BlobFieldName + ' = :ABlob where '+ KeyFieldName +' = :ATableID';
if VarType (KeyID) = varString then
qryBlobManager.ParamByName ('ATableID').dataType := ftString
else
qryBlobManager.ParamByName ('ATableID').dataType := ftInteger;
qryBlobManager.ParamByName ('ATableID').Value := KeyID;
qryBlobManager.ParamByName ('ABlob').AsBlob := Stream.DataString;
try
qryBlobManager.Transaction := FTransactions.StartTrans
(ATransName);
qryBlobManager.ExecSql;
Commit (ATransName);
except
on E:Exception do
begin
Rollback;
if not TryNetRecover (E, 'Error updating blob in ' +
TableName) then
raise;
end; { on }
end; { try except }
finally
Stream.Free;
end; { try finally }
end; { TdmFBDatabase.SaveBlobToDatabase }
The qryBlobManager is really an IBQuery.
Hope this helps.
-Eduardo
<jesus_martinez1967@...> wrote:
> i have still problems when trying to execute anPlease do not laugh at the code below but,... assuming you are using
> INSERT statement to a blob.
>
> i have txts that are more bigger than 16 kb,
> i tried to do
>
> INSERT INTO my table (MYBLOBfield)values (here i copy
> pasted my txt bigger than 16kb)
Delphi, we have no problem with size and something like:
function TdmFBDatabase.SaveBlobToDatabase(TableName, KeyFieldName,
BlobFieldName: string; KeyID: variant; Blob: TStream;
ATransName: string = DefaultTrans): integer;
var Stream: TStringStream;
begin
Result := 0;
Stream := TStringStream.Create ('');
Stream.CopyFrom (Blob, 0);
try
qryBlobManager.SQL.Text := 'update '+TableName+' set '+
BlobFieldName + ' = :ABlob where '+ KeyFieldName +' = :ATableID';
if VarType (KeyID) = varString then
qryBlobManager.ParamByName ('ATableID').dataType := ftString
else
qryBlobManager.ParamByName ('ATableID').dataType := ftInteger;
qryBlobManager.ParamByName ('ATableID').Value := KeyID;
qryBlobManager.ParamByName ('ABlob').AsBlob := Stream.DataString;
try
qryBlobManager.Transaction := FTransactions.StartTrans
(ATransName);
qryBlobManager.ExecSql;
Commit (ATransName);
except
on E:Exception do
begin
Rollback;
if not TryNetRecover (E, 'Error updating blob in ' +
TableName) then
raise;
end; { on }
end; { try except }
finally
Stream.Free;
end; { try finally }
end; { TdmFBDatabase.SaveBlobToDatabase }
The qryBlobManager is really an IBQuery.
Hope this helps.
-Eduardo