Skip to Content
0
Former Member
Nov 18, 2014 at 02:40 PM

Invalid column name; mismatched column in set (UNION ALL)

2345 Views

I saw the Jody's proposed solution in this thread: which seems great (which it probably is) and now I am trying to do the same, but it does not seem to work as I hoped.

PROCEDURE temp (IN a; OUT b)

...

DECLARE cond ...

...

CALL proc_demo(c); -- c is returned (OUT) from proc_demo and contains columns 'id' & 'ref'

b = SELECT id AS field1 FROM :c WHERE ref = cond

UNION ALL

SELECT * FROM :a WHERE ref = cond;

Note: 'a' is based on an ABAP dictionary table and contains no column 'id', but column 'field1' among others.

The syntax error is: "Invalid column name; mismatched column in set (UNION ALL)"

Just for testing I also tried (which gives the same error):

b = SELECT field1 AS field1 FROM :a WHERE ref = cond

UNION ALL

SELECT * FROM :b WHERE ref = cond;

I would appreciate any help on this. Please note I am new to SQL so pls explain on a basic level 😊