Subject | Re: [ib-support] Using BLOB SUB_TYPE 1 as parameter |
---|---|
Author | Helen Borrie |
Post date | 2003-04-10T22:43:01Z |
At 10:14 PM 10/04/2003 +0000, you wrote:
You can't do a blob-to-blob comparison directly - you need a UDF.
You can do:
SELECT blob_field FROM test_table WHERE blob_field CONTAINING ?
as long as you pass a string to the parameter.
And you say that this works too?
SELECT blob_field FROM test_table WHERE blob_field = 'abc'
If so, that's good. Claudio added the capability to cast a string to a
text blob transparently, a long time ago.
The problem with this one:
SELECT blob_field FROM test_table WHERE blob_field = ?
may be that the API doesn't know the type of the parameter, whereas
presenting the literal string provides this information explicitly. Could
you try this:
SELECT blob_field FROM test_table WHERE blob_field = cast (? as Varchar(80))
heLen
>Hi,Roman,
>
>Originally this problem was reported in Firebird-Java. We have found
>that following statement fails (test case had different metadata, but
>I think this is not very important here):
>
>SELECT blob_field FROM test_table WHERE blob_field = ?
>
>Table is defined as CREATE TABLE test_table(blob_field BLOB SUB_TYPE 1).
>
>JayBird' algorithm for executing this statement can be described as
>following:
>
>1. isc_dsq_prepare(...) // prepare statement
>2. isc_create_blob2 // create blob that will be used as param value
>3. isc_put_segment // fill parameter value
>4. set id of that blob into out_sqlda
>5. isc_dsql_execute2
>6. isc_dsql_fetch
>
>At this point we get "internal error" (error code 335544384,
>isc_badblk) from the server.
>
>Question: what is wrong with this code? How do I prepare statement
>with condition that involves comparison with BLOB SUB_TYPE 1 column?
>(btw, if we replace "?" with string constant, like, 'abc', everything
>is fine).
>
>Thank you in advance for any hints.
>
>Best regards,
>Roman Rokytskyy
You can't do a blob-to-blob comparison directly - you need a UDF.
You can do:
SELECT blob_field FROM test_table WHERE blob_field CONTAINING ?
as long as you pass a string to the parameter.
And you say that this works too?
SELECT blob_field FROM test_table WHERE blob_field = 'abc'
If so, that's good. Claudio added the capability to cast a string to a
text blob transparently, a long time ago.
The problem with this one:
SELECT blob_field FROM test_table WHERE blob_field = ?
may be that the API doesn't know the type of the parameter, whereas
presenting the literal string provides this information explicitly. Could
you try this:
SELECT blob_field FROM test_table WHERE blob_field = cast (? as Varchar(80))
heLen