Fix Error “ORA-01789: query block has incorrect number of result columns”

If you’re getting the error “ORA-01789: query block has incorrect number of result columns” in Oracle Database, then it’s probably because you’re trying to use an operator such as UNION, INTERSECT, or EXCEPT to run a compound query, but the SELECT statements on either side of the operator return a different number of columns.

To fix this, simply ensure that both queries return the same number of columns.

Continue reading

Fix Error “ORA-01790: expression must have same datatype as corresponding expression”

If you’re getting the error “ORA-01790: expression must have same datatype as corresponding expression” in Oracle Database, it’s probably because you’re using an operator such as UNION, INTERSECT, or EXCEPT to run a compound query, but the columns returned by each query use different data type groups.

To fix this issue, you’ll need to ensure that each column returned by the second query uses the same data type group as the corresponding column in the first query.

Continue reading