Subject Re: [Firebird-Java] Re: Obscure error
Author William L. Thomson Jr.
On Fri, 2003-02-07 at 02:18, Roman Rokytskyy wrote:
> > An empty string is not the same as a null string and by extension
> > I would say that an empty blob is not the same as a null blob
> > either. In your application you may decide that an empty blob
> > should be null. And perhaps the JDBC spec equates the two. The
> > SQL standard does not.
>
> What is empty blob? Does it have some special ID? How can I generate
> empty blob?

I think one way I was able to do it was like this

byte[] picture;

picture = " ".getBytes();


Now go insert picture using JayBird into a blob field, and you should
have an empty blob that is not null.

> Reported error happens when server returns blob ID 0 (or at least it
> is decoded as 0). However in driver this value is an indicator to
> create new blob. JayBird creates it and waits for a client to start
> writing data into it. However, this blob belongs to SELECT and client
> tries to read from newly created blob. Since this operation makes
> little sense to driver, it raises an exception.
>
> Now question: can blob ID be 0? Does it mark empty blob?

From the way things went I assume that a blob ID can be 0 if it's length
is less than say 8 characters?

I had blobs that weren't null, but threw that exception. So there ID
must have been 0?

I would check out the InterClient code on this. Since InterClient would
not throw and exception, but it would catch it when I did.

resultSet.getBytes("picture")!=null;

JayBird would not make it that far, because it will through the
exception.

So it could be addressed in the driver by saying that if a blob id is 0
during a select statement, that it's a null blob. Which will also
prevent the exception from being thrown.

However I personally think the driver should remain as is. That way
people like Simon and I do not build bad habits on how data is stored in
our db's.

If it's weren't for JayBird throwing the exception, It may have been
years down the road, before I would catch my mistake.

I leave that decision up to the JayBird development team.

--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com