Subject Re: [firebird-support] Problem with using string operator in UNION?
Author Martijn Tonies
Hi,

> Is there any way to do a UNION and use the string operator || ?

Sure.

> I found another way to do this. Its just to fill a combobox, but still
> wondering why the problem.
>
> Each half of the UNION works fine on its own.
>
> I keep getting
> SQL error code -104
> Invalid command
> Data type unknown
>
> for the following (its the field with || in it)
>
> select v1.ml_item || '/' || v2.ml_item as Root_Node ,

cast ((v1.ml_item || '/' || v2.ml_item) as
varchar(enter_nr_of_characters_here) ) as Root_Node,

> v1.ml_id as id,
> v2.ml_parentid ,
> v1.root_id
> from masterlibrary v1, masterlibrary v2
> where v1.root_id = v2.ml_parentid
> and v1.ml_parentid = -1
> UNION
> select as Root_Node ,

cast ((v3.ml_item || '/') as varchar(same_nr_as_above) ) as Root_Node,

> v3.ml_id as id,
> v3.ml_parentid ,
> v3.root_id
> from masterlibrary v3
> where v3.ml_id = v3.root_id
> order by 1

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com