Problem Note 65766: Ambiguous column or duplicate column errors might occur when running a query against a database
When you use SAS® 9.4M6 (TS1M6) with Hot Fix D9T069 and run an SQL procedure query, you might see an error related to an ambiguous column reference or duplicate column name. The problem might occur under the following scenario:
- You create VIEW1 that references a database management system (DBMS) table in which the columns in the SELECT statement are renamed. Here is an example: create view1 as select var1 as var1_1, var2 as var2_1 from dblib.table1
- You create VIEW2 that references a different DBMS table in which the table contains one of the variables in VIEW1 but it is not being renamed. Here is an example: create view2 as select var1, var4 from dblib.table2
- You create VIEW3 that references a third DBMS table in which a variable that matched with one of the variables in VIEW1 is renamed to the same name. Here is an example: create view3 as select var1 as var1_1, var5, var6 from dblib.table3
- You create VIEW4 that joins VIEW2 and VIEW1 on the variable in common that was renamed in VIEW1 but not renamed in VIEW2 and then select the other variable in VIEW1 and rename it to the same name and include that variable in the ORDER BY clause. Here is an example: create view4 as select t2.var2_1 as var2_1 from view2 t1 inner join view1 t2 on t1.var1=t2.var2_1 order by t2.var2_1
- You create VIEW5 that joins VIEW3 and VIEW1 on the variable that is in common that was renamed in both views. Here is an example: create view5 as select t2.var2_1 from view3 t1 inner join view1 t2 on t1.var1_1=t2.var1_1
- You create a table in which you perform a full join of VIEW5 and VIEW4 on the renamed variable and create a new variable using a CASE expression in which the variable from both tables is used and give it the same name. Here is an example: create table results as select case when t1.var2_1 is missing then t2.var2_1 else t1.var2_1 end as var2_1 from view5 t1 full join view4 t2 on t1.var2_1 =t2.var2_1
Here are some of the errors that have been encountered due to this issue:
ACCESS ENGINE: ERROR: CLI prepare error: [SAS][ODBC Redshift Wire Protocol driver][Redshift]ERROR: column reference "ABC" is ambiguous(File /home/ec2-user/padb/src/pg/src/backend/parser/parse_relation.c; Line 551; Routine scanRTEForColumn; )
ACCESS ENGINE: ERROR: Teradata prepare: Duplication of column ABC in a table, derived table, view, macro or trigger.
DB2 ERROR:
RESULT OF SQL STATEMENT:
DSN00203E A REFERENCE TO COLUMN VAR2_1 IS AMBIGUOUS
A DUMP OF THE SQLCA FOR THE GET DIAGNOSTICS REQUEST FOLLOWS:
ROW NUMBER: 0 ERROR CONDITION: 1 REASON CODE: 0
SQLCODE: -203 SQLSTATE: 42702 SQLERRP: DSNXORSO
ACCESS ENGINE: ERROR: ORACLE prepare error: ORA-00918: column ambiguously defined.
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4 TS1M6 | |
z/OS 64-bit | 9.4 TS1M6 | |
Microsoft® Windows® for x64 | 9.4 TS1M6 | |
Microsoft Windows 8 Enterprise 32-bit | 9.4 TS1M6 | |
Microsoft Windows 8 Enterprise x64 | 9.4 TS1M6 | |
Microsoft Windows 8 Pro 32-bit | 9.4 TS1M6 | |
Microsoft Windows 8 Pro x64 | 9.4 TS1M6 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 TS1M6 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4 TS1M6 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4 TS1M6 | |
Microsoft Windows 8.1 Pro x64 | 9.4 TS1M6 | |
Microsoft Windows 10 | 9.4 TS1M6 | |
Microsoft Windows Server 2012 Datacenter | 9.4 TS1M6 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 TS1M6 | |
Microsoft Windows Server 2012 R2 Std | 9.4 TS1M6 | |
Microsoft Windows Server 2012 Std | 9.4 TS1M6 | |
Microsoft Windows Server 2016 | 9.4 TS1M6 | |
Microsoft Windows Server 2019 | 9.4 TS1M6 | |
Windows 7 Enterprise 32 bit | 9.4 TS1M6 | |
Windows 7 Enterprise x64 | 9.4 TS1M6 | |
Windows 7 Home Premium 32 bit | 9.4 TS1M6 | |
Windows 7 Home Premium x64 | 9.4 TS1M6 | |
Windows 7 Professional 32 bit | 9.4 TS1M6 | |
Windows 7 Professional x64 | 9.4 TS1M6 | |
Windows 7 Ultimate 32 bit | 9.4 TS1M6 | |
Windows 7 Ultimate x64 | 9.4 TS1M6 | |
64-bit Enabled AIX | 9.4 TS1M6 | |
64-bit Enabled Solaris | 9.4 TS1M6 | |
HP-UX IPF | 9.4 TS1M6 | |
Linux for x64 | 9.4 TS1M6 | |
Solaris for x64 | 9.4 TS1M6 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Problem Note |
Priority: | high |
Date Modified: | 2020-04-08 12:38:57 |
Date Created: | 2020-03-26 22:13:24 |