简体   繁体   English

将Oracle与MSSQL表连接

[英]Joining oracle with mssql table

When i execute following line i get the result: 当我执行以下行时,我得到结果:

select * from my_table@link; 

But when i try to join linked table with other tables like in select i get error that says "z.id - invalid identifier" 但是,当我尝试将链接表与其他表(如在选择中)连接时,出现错误,提示“ z.id-无效标识符”

SELECT

                e.USER_NAME,e.FULL_NAME,r.RFC_NUMBER,r.TYPE, 

                TO_CHAR(TRUNC(a.TOTAL_TIME/3600),'FM9900') || ':' ||
                TO_CHAR(TRUNC(MOD(a.TOTAL_TIME,3600)/60),'FM00') || ':' ||
                TO_CHAR(MOD(a.TOTAL_TIME,60),'FM00') as TOTAL_TIME,

                a.ASSIGN_DATE,a.TIME_START,a.TIME_STOP,
                r.SUBMITTED_BY,r.REGISTER_DATE,r.DESCRIPTION 


                FROM table_a a 
                JOIN table_r ON a.REQ_ID = r.REQ_ID 
                JOIN table_e e ON e.emp_id = a.emp_id

                LEFT JOIN my_table@link z ON e.emp_id = z.id

                WHERE a.ASSIGN_DATE > '01-JAN-2013' and a.ASSIGN_DATE < '01-JAN-2015'

                ORDER BY r.RFC_NUMBER;

table_a, table_r and table_e are oracle tables. table_a,table_r和table_e是oracle表。 table my_table is mssql table that is being accessed via link. 表my_table是通过链接访问的mssql表。

so my question is how to join oracle tables with linked mssql table? 所以我的问题是如何将Oracle表与链接的mssql表联接在一起?

From your comments I believe the issue is that SQL Server uses case-sensitive column names by default (more specific information can be found at this link ), while Oracle will only use case-sensitive column names if these are enclosed in double quotes " . So if the column id in your SQL Server table is lowercase, you'll need to use quotes around this column name in Oracle. That is, if you don't put quotes around a column name in Oracle, it assumes uppercase. So z.id will look for a column named ID while z."id" will look for a column named id . Specifically, this line: 从你的意见,我认为这个问题是SQL Server的默认使用区分大小写的列名(更具体的信息可以在这个链接找到 ),而如果这些都包含在双引号甲骨文将只使用区分大小写的列名" 。因此,如果列id在你的SQL Server表是小写的,你需要使用围绕甲骨文此列名引号。也就是说,如果你不把周围的Oracle列名引号,它假定大写的。所以z.id将查找名为ID的列,而z."id"将查找名为id的列。

LEFT JOIN my_table@link z ON e.emp_id = z.id

should be this: 应该是这样的:

LEFT JOIN my_table@link z ON e.emp_id = z."id"

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM