DelphiFAQ Home Search:

Union in InterBase delivers '-104 Data type unknown'

 

comments3 comments. Current rating: 5 stars (3 votes). Leave comments and/ or rate it.

I just had to make a triple union (= 3 select statements) which gave me this error message:

Dynamic SQL Error
-SQL error code = -104
-Invalid command
-Data type unknown


Each on its own, the 3 SQL statements worked fine. Also combining the first and second worked.
The 3rd one contained an additional constant string..

The SQL statements are in the box below.. once I added the CAST (expression AS CHAR(128)), it worked.

The puzzling thing is that select statements 1 and 2 already contained those string constants 'P_' and '_A_'... so why would the union of those two work without a cast? Questions over questions, but the triple union below needs the casts - then it works.

select cast (upper('P_' || p.name || '_A_' || a.name) as char(128)) as fname
[..]

union

select cast (upper('P_' || p.name || '_A_' || a.name) as char(128)) as fname
[..]

union

select cast (upper('P_' || p.name || '_A_' || 'World') as char(128)) as fname
[..]

Comments:

2006-03-29, 08:47:05
anonymous from United States  
rating
I realized my mistake as soon as I saw this and can explain what went wrong. The union requires the exact same type and LENGTH. When the third select used a constant instead of a.name, it was no longer the same length of 128 or more correctly the length of p.name and a.name.
2006-08-29, 10:05:14
anonymous from Belarus  
rating
2006-11-09, 05:36:04
anonymous from Netherlands  
rating
After developing for over 12 years with Oracle as the backend i'm spoiled with oracle's implicit type casting.
Had been struggling for a couple of hours with a new view before starting googling for the solution. Thanks.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: