Subject Re: [ib-support] Re: UDFs returning BLOB cause error -804
Author Claudio Valderrama C.
""mircostange"" <mirco@...> wrote in message
news:a5ig32+iskh@......
>
> > Yes, it's the right place. :))
> >
> > -804 is returned when you call an unknown function...did you
> declare your
> > functions to the database?

But in such case, it would say instead:

Statement failed, SQLCODE = -804

Dynamic SQL Error
-SQL error code = -804
-Function unknown
-F_STRBLOB


> Yes, I did. There is a free udf lib that has a strblob function. As I
> understand, it's supposed to take a string and return a blob. I
> declared it with
>
> declare external function f_StrBlob
> cstring(254),
> blob
> returns parameter 2
> entry_point 'StrBlob' module_name 'FreeUDFLib.dll';

That's almost equivalent to the string2blob() function in the fbudf.


> However, when I try to execute:
>
> select f_strblob('X') from sampletype

This is not supported by DSQL.

SQL> select string2blob('hello') from rdb$database;

STRING2BLOB
=================
Statement failed, SQLCODE = -804

Dynamic SQL Error
-SQL error code = -804
-SQLDA missing or incorrect version, or incorrect number/type of variables

If you throw the substring() in the middle, you will return to string. But
you can do a workaround:

SQL> set term ^;
SQL> create procedure p2b(i varchar(300)) returns(o blob) as begin o =
string2blob(i); suspend; end^
SQL> set term ;^

SQL> select * from p2b('hello');

O
=================

0:cc21ac
=====================================================
O:
BLOB display set to subtype 1. This BLOB: subtype = 0

=====================================================

SQL> set blob 0;
SQL> select * from p2b('hello');

O
=================

0:cc0c10
=====================================================
O:
hello
=====================================================

I don't know really what do you want to do. For converting between two blob
types, there are special udfs called blob filters, poorly documented
however. It's strange that you want to convert a string to blob and then
pass it to the calling application. It almost has no sense. This trick was
needed when you had to convert a string to blob before inserting it into a
blob field (otherwise, use parameterized queries) but that now inserting
literal strings into blob fields is supported directly by Firebird.

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing