Subject Re: [ib-support] invalid Blod ID error on Firebird
Author Theo Bebekis
Hi

Helen is right, we're getting into the realm of "off-topic" for this list
but I believe that this topic may benefit many people, so here is
my tiny contribution

I use blobs and stored procedures quite often.
Never had any problem.

Here is some code from my projects (I use IBX)


A. inserting/updating
---------------------
create procedure Misc_Data_Insert
(
NAME varchar(60),
DATA_BLOB BLOB // it could be SUB_TYPE TEXT
)
as
....


Delphi side

a. SP.ParamByName('DATA_BLOB').LoadFromStream(MS, ftBlob);
b. Q.ParamByName('DATA_BLOB').Assign(List);


SP is a TIBStoredProc component
MS is a TMemoryStream
Q is a TIBQuery
List is a TStrings

NOTE : check the TParam.Assign(Source: TPersistent); code. (DB.pas)
It seems that the method is capable of handling TStrings
and TStream objects as well


B. selecting
--------------
create procedure Misc_Data_Select
( NAME VARCHAR(60) )
RETURNS
(
RESULT INTEGER,
DATA_BLOB BLOB
)
as
...

Delphi side

a. TBlobField(Q.FieldByName('DATA_BLOB')).SaveToStream(MS);
MS.Position := 0;
b. List.Assign(TBlobField(Q.FieldByName('DATA_BLOB')));


I think there is an issue regarding blobs and stored procs
IIRC the documentation, but the above works fine for me.

Regards
Theo
-----------------------------------
Theo Bebekis
Thessaloniki, Greece
bebekis@...
teo@...
-----------------------------------
----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <ib-support@yahoogroups.com>
Sent: Friday, December 06, 2002 2:03 AM
Subject: RE: [ib-support] invalid Blod ID error on Firebird


> At 05:08 PM 05-12-02 -0600, you wrote:
> >Helen,
> >thanks for reply - the following is the delphi procedure.
> >This code is unchanged from code that worked with the
> >Borland Open Source 1.0 release and as I said I am
> >using IBX (Interbase Tab)
> >
> >So are you saying that the Firebird side is not accepting the
> >.AsBlob
>
> It won't be Firebird, per se, but that your application is not passing a
> parameter of the type expected by the stored procedure.
>
> You still haven't provided the declarations for the input parameters for
> this SP. This is where you have to look.
>
> Firebird differs from (advances from) IB 6 wrt blob inputs, insofar as it
> will accept a string as input to a blob column. However, it hasn't changed
> anything wrt to blob inputs, i.e. if you pass a blob in a blob parameter,
> it will process it just as IB 6 did. So we are not looking at Firebird
> doing something different with blobs than IB 6 did.
>
> This line may be causing your problems on the application side:
>
> ParamByName('iCallDetailMemo').AsBlob :=
> CallLog.Lines.Text; -------------------Here is blob info
>
> Try changing this to
>
> ParamByName('iCallDetailMemo').AsString := CallLog.Lines.Text;
>
> This should work properly regardless of whether the SP expects a blob or a
> string as input.
>
> I'd also go further and protect it from errors in null text with
> if CallLog.Lines.Count > 0 then
> ParamByName('iCallDetailMemo').AsString := CallLog.Lines.Text
> else
> ParamByName('iCallDetailMemo').Clear;
>
> We're getting into the realm of "off-topic" for this list. I suspect the
> crucial question here is still the input type that your SP expects.
>
> heLen