Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread How to include a NULL BLOB field in a SQL statement
Tue, Sep 10 2013 9:52 AMPermanent Link

Hedley Muscroft

Hi - I have a UNION'ed query which needs to include a NULL field as BLOB field. Here's a simplified version of the SQL :-

select per.id as per_id, per.name, per.portrait from per
union
select auxper.master_per_id as per_id, auxper.name, cast(null as blob) as portrait from auxper

The problem occurs with the "cast(null as blob) as portrait" :-

ElevateDB Error #700 An error was found in the statement at line 1 and column 1726 (Invalid expression "portrait" found, BLOB expressions not allowed)

Please can you tell me how to accomplish the above?

Many thanks!

Hedley Muscroft
Pioneer Software
Tue, Sep 10 2013 10:09 AMPermanent Link

Uli Becker

Hedley,

> Please can you tell me how to accomplish the above?

Union all instead of union should work:

select per.id as per_id, per.name, per.portrait from per
union all
select auxper.master_per_id as per_id, auxper.name, cast(null as blob)
as portrait from auxper

Regards Uli
Tue, Sep 10 2013 10:14 AMPermanent Link

Hedley Muscroft

Well blow me down - it does indeed work... although I'm not sure I understand why UNION ALL should work while UNION doesn't?!

Thanks Uli.
Tue, Sep 10 2013 11:01 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Hedley

>Well blow me down - it does indeed work... although I'm not sure I understand why UNION ALL should work while UNION doesn't?!

Surprises me as well. A wild guess as to the reason UNION ALL simply adds all of the rows without any checking. A UNION checks to make sure there are no duplicates. If you then think a BLOB can be a couple of gig in size I suspect that Tim didn't want complaints about the speed of the SQL due to the "small" amount of time required for the comparison.

Just a guess though.

Roy
Tue, Sep 10 2013 1:01 PMPermanent Link

Uli Becker

Hedley,

> Well blow me down - it does indeed work... although I'm not sure I understand why UNION ALL should work while UNION doesn't?!

I don't know why this work either. I just remembered a similar problem I
had some time ago.

Uli
Wed, Sep 11 2013 1:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Hedley,

<< Well blow me down - it does indeed work... although I'm not sure I
understand why UNION ALL should work while UNION doesn't?! >>

Duplicate removal - EDB uses indexes for duplicate checking/removal, and you
can't use BLOB columns with indexes.

Tim Young
Elevate Software
www.elevatesoft.com
Image