Subject Re: [firebird-support] Re: Passing a blob to a stored procedure
Author Helen Borrie
At 11:30 AM 10/06/2004 +0000, you wrote:
>--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
>wrote:
> > At 09:34 AM 10/06/2004 +0000, you wrote:
> > >Procedure
> > >The script as I run.
> > >
> > >CREATE PROCEDURE INSERT_TRANSACTIONEX(
> > > TRANS_ID VARCHAR(22),
> > > CELL_NUMBER VARCHAR(15),
> > > THE_MESSAGE BLOB SUB_TYPE 1,
> > > MSG_ID VARCHAR(8),
> > > STATUS CHAR(1),
> > > USER_ID VARCHAR(20),
> > > VIS CHAR(1),
> > > CONTNAME CHAR(50))
> > >AS
> > >BEGIN
> > > INSERT INTO TRANSACTIONS
> > >(TRANSID,CELLNUMBER,THEMESSAGE,MSGID,STATUS,THETIMESTAMP,USERID,
> > >VISIBLE,CONTACTNAME)
> > > VALUES
> > >
>(:TRANS_ID, :CELL_NUMBER, :THE_MESSAGE, :MSG_ID, :STATUS, 'now', :USER
> > >_ID,:VIS,:CONTNAME);
> > >END;
> > >
> > >I execute the procedure with the following line.
> > >
> > >EXECUTE PROCEDURE INSERT_TRANSACTIONEX('1','123','test
> > >message','123','1','testuser','T','test user')
> > >
> > >I get an internal error in ib admin.
> >
> > The string 'test message' isn't a blob, it's a string. The
>procedure
> > expects a blob as input. If you're using Firebird, change the
>input
> > parameter declaration to a suitably sized varchar and it should
>compile. If
> > you're using InterBase, you'll have to do something a bit more
>complicated
> > inside the SP to convert the string to a blob, i.e. call a UDF such
>as
> > String2Blob.
> >
> > /heLen
>
>I wanted to use a BLOB to get around the size limit associated with a
>varchar. Is there a way I can pass a BLOB directly form a SQL
>statement?

Through the API, via a blob control structure. Some interface layers
encapsulate the structure for you and provide the means to pass the byte
stream to a replaceable parameter. Depends on what you're using as your
application interface layer...

In Firebird 1.5, you can pass an expression in a SP parameter, so it's
feasible just to use the String2Blob UDF(in fbudf) for literal statements
like yours.

/heLen