Mega Code Archive

 
Categories / Delphi / Examples
 

Union in interbase delivers -104 data type unknown

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 [..]