Saving To Text based BLOB field
Saving To Text based BLOB field
Does anyone know the best way to post a TStringList to a Memo based BLOB field with IBDAC? I can't seem to find a good way to do this. Posting with Data Aware controls works fine, but using SQL with Params doesn't seem to do the trick.
Thanks,
Rhett Price
IndySoft
Thanks,
Rhett Price
IndySoft
You can do it in a several manners:
Using DataSet (i.e. TIBCQuery) you can do the following:
Using params and TIBCSQL:
Using DataSet (i.e. TIBCQuery) you can do the following:
Code: Select all
var
StringList: TStringList;
IBCQuery: TIBCQuery;
begin
....
IBCQuery.SQL.Text := 'SELECT ID, BLOB_FIELD FROM BLOB_TABLE ';
IBCQuery.Open;
....
IBCQuery.Edit;
IBCQuery.FieldByName('BLOB_FIELD').Assign(StringList);
IBCQuery.Post;
//If IBCQuery.AutoCommit is False (default) you should manually commit all changes
IBCQuery.Transaction.CommitRetaining; //If IBCQuery.UpdateTransaction is set than you should use
//IBCQuery.UpdateTransaction.Commit; instead
Using params and TIBCSQL:
Code: Select all
var
StringList: TStringList;
IBCSQL: TIBCSQL;
IBCQuery: TIBCQuery;
begin
...
//NOTE: IBCQuery.Transaction.Params should be set to READ COMMITTED isolation level
IBCQuery.SQL.Text := 'SELECT ID, BLOB_FIELD FROM BLOB_TABLE ';
IBCQuery.Open;
....
IBCSQL.SLQ.Text := 'UPDATE BLOB_TABLE SET BLOB_FIELD = :BLOB_FIELD WHERE (ID = :ID)'
....
IBCSQL.ParamByName('ID').AsInteger := 1;
IBCSQL.ParamByName('BLOB_FIELD').AsString := StringList.Text;
IBCSQL.Execute;
IBCSQL.Transaction.Commit;
....
IBCQuery.Refresh;
Saving To Text based BLOB field
Thanks for the response - I'm still getting errors on the 2 methods you mentionned. I am using the Delphi 5 version of IBDAC. Here are some notes:
------------------------
** METHOD 1 (parameters):
procedure TBlankMainForm.UpdateACommentWithListTest(sTable, sField, sWhere: String; mMemo: TStrings);
begin
if ((sTable = '') or (sField = '')) then exit;
ibQueryTemp.Close;
ibQueryTemp.SQL.Clear;
ibQueryTemp.SQL.Text := 'UPDATE ' + sTable + ' SET ' + sField + ' = :MEMOTEMP ' + sWhere;
ibQueryTemp.ParamByName('MEMOTEMP').AsString := mMemo.Text;
ibQueryTemp.Execute;
end;
- Returns the error:
Dynamic SQL Error
SQL error code = -303
feature is not supported
BLOB and array data types are not supported for move operation
- the blob type I'm attempting to update is:
BLOB sub_type 1 segment size 80
- Here is the TIBCQuery object from dfm:
object ibQueryTemp: TIBCQuery
Connection = IBCConnection1
FetchAll = True
AutoCommit = True
Left = 588
Top = 216
end
------------------------
** METHOD 2 (edit):
procedure TBlankMainForm.UpdateACommentWithListTest(sTable, sField, sWhere: String; mMemo: TStrings);
var
slTemp : TStringList;
begin
if ((sTable = '') or (sField = '')) then exit;
IBCQuery2.Close;
IBCQuery2.SQL.Clear;
// selects all key fields and memo field (sField)
IBCQuery2.SQL.Text := 'SELECT EVENT_NUM, ATTRIBUTE_NAME, COMPANY, GAGE_SN ' + sField + ' FROM ' + sTable + ' ' + sWhere;
IBCQuery2.Open;
slTemp := TStringList.Create;
try
slTemp.Text := mMemo.Text;
IBCQuery2.Edit;
IBCQuery2.FieldByName(sField).Assign(slTemp);
IBCQuery2.Post;
finally
slTemp.Free;
end;
end;
- if I do not have TFields created for IBCQuery2, running the code above returns the error:
Cannot assign a TStringList to a TStringField
- if I have TFields created for IBCQuery2, with my blob field declared as TMemoField, returns the error:
IBCQuery2: Type mismatch for field 'ATTRIBUTE_AS_MEMO', expecting: Memo actual String.
------------------------
** METHOD 1 (parameters):
procedure TBlankMainForm.UpdateACommentWithListTest(sTable, sField, sWhere: String; mMemo: TStrings);
begin
if ((sTable = '') or (sField = '')) then exit;
ibQueryTemp.Close;
ibQueryTemp.SQL.Clear;
ibQueryTemp.SQL.Text := 'UPDATE ' + sTable + ' SET ' + sField + ' = :MEMOTEMP ' + sWhere;
ibQueryTemp.ParamByName('MEMOTEMP').AsString := mMemo.Text;
ibQueryTemp.Execute;
end;
- Returns the error:
Dynamic SQL Error
SQL error code = -303
feature is not supported
BLOB and array data types are not supported for move operation
- the blob type I'm attempting to update is:
BLOB sub_type 1 segment size 80
- Here is the TIBCQuery object from dfm:
object ibQueryTemp: TIBCQuery
Connection = IBCConnection1
FetchAll = True
AutoCommit = True
Left = 588
Top = 216
end
------------------------
** METHOD 2 (edit):
procedure TBlankMainForm.UpdateACommentWithListTest(sTable, sField, sWhere: String; mMemo: TStrings);
var
slTemp : TStringList;
begin
if ((sTable = '') or (sField = '')) then exit;
IBCQuery2.Close;
IBCQuery2.SQL.Clear;
// selects all key fields and memo field (sField)
IBCQuery2.SQL.Text := 'SELECT EVENT_NUM, ATTRIBUTE_NAME, COMPANY, GAGE_SN ' + sField + ' FROM ' + sTable + ' ' + sWhere;
IBCQuery2.Open;
slTemp := TStringList.Create;
try
slTemp.Text := mMemo.Text;
IBCQuery2.Edit;
IBCQuery2.FieldByName(sField).Assign(slTemp);
IBCQuery2.Post;
finally
slTemp.Free;
end;
end;
- if I do not have TFields created for IBCQuery2, running the code above returns the error:
Cannot assign a TStringList to a TStringField
- if I have TFields created for IBCQuery2, with my blob field declared as TMemoField, returns the error:
IBCQuery2: Type mismatch for field 'ATTRIBUTE_AS_MEMO', expecting: Memo actual String.
Sure thing. I will send to support. Thanks for the help.
Alex wrote:We couldn't reproduce this problem. We need more detailed description of it.
Please specify Table DDL SQL, client and server versions, IBDAC version.
Also send small complete sample project with scripts creating server side objects to IBDAC support address if possible.
In case anyone is curious, here is how support told us to update a Notes based BLOB field. This method works just fine.
IBCSQL1.SQL.Text := 'INSERT INTO IBDAC_BLOB_TEXT (Code, Title, Val) VALUES (100, ''TEST'', :BLOB_FIELD)';
IBCSQL1.ParamByName('BLOB_FIELD').DataType := ftBlob; //<<<<<<<< Here we set right param datatype
IBCSQL1.ParamByName('BLOB_FIELD').ParamType := ptInput; //<<<<<<<< Here we set right ParamType
IBCSQL1.ParamByName('BLOB_FIELD').AsString := StringList.Text;
IBCSQL1.SQL.Text := 'INSERT INTO IBDAC_BLOB_TEXT (Code, Title, Val) VALUES (100, ''TEST'', :BLOB_FIELD)';
IBCSQL1.ParamByName('BLOB_FIELD').DataType := ftBlob; //<<<<<<<< Here we set right param datatype
IBCSQL1.ParamByName('BLOB_FIELD').ParamType := ptInput; //<<<<<<<< Here we set right ParamType
IBCSQL1.ParamByName('BLOB_FIELD').AsString := StringList.Text;
i have this problem too. If i want to fill Data over Parameter in a Textblob-field, i have this error:
BLOB and array data types are not supported for move operation
I use Delphi 7 Prof und IBDAC2.
Sorry for my bad English...
this doesnt work:
BLOB and array data types are not supported for move operation
I use Delphi 7 Prof und IBDAC2.
Sorry for my bad English...
this doesnt work:
IBCSQL1.ParamByName('BLOB_FIELD').DataType := ftBlob; //<<<<<<<< Here we set right param datatype
IBCSQL1.ParamByName('BLOB_FIELD').ParamType := ptInput; //<<<<<<<< Here we set right ParamType
IBCSQL1.ParamByName('BLOB_FIELD').AsString := StringList.Text;