Sql-Server

從 SQL Server Openquery 向 Oracle 傳遞萬用字元

  • April 4, 2017

我想像這樣從 MS SQL Server 向 Oracle 傳遞萬用字元…

SELECT * FROM OPENQUERY(MY_LINKED_ORACLE_SERVER, 'SELECT * FROM MY_ORACLE_TABLE')

我正在嘗試從表 MY_ORACLE_TABLE 中獲取所有內容。

我得到以下輸出…

OLE DB provider "OraOLEDB.Oracle" for linked server "MY_LINKED_ORACLE_SERVER" returned message "ORA-01861: literal does not match format string
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PERS_GET_SERVICE_LENGTH", line 43
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PERS_GET_SERVICE_LENGTH", line 68
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PRBI_GET_LENGTH_OF_SERVICE", line 9".
OLE DB provider "OraOLEDB.Oracle" for linked server "MY_LINKED_ORACLE_SERVER" returned message "ORA-01861: literal does not match format string
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PERS_GET_SERVICE_LENGTH", line 43
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PERS_GET_SERVICE_LENGTH", line 68
ORA-06512: at "OPS$MY_LINKED_ORACLE_SERVER.PRBI_GET_LENGTH_OF_SERVICE", line 9".
Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT * FROM MY_ORACLE_TABLE" against OLE DB provider "OraOLEDB.Oracle" for linked server "MY_LINKED_ORACLE_SERVER".  

看起來某些內容的格式不符合 SQL Server 的喜好,但由於我不知道遠端 Oracle 伺服器上存在哪些列名(而且我無法找到),這是否可以修復?

該錯誤是由 Oracle 端的失敗函式引起的。“SELECT * FROM MY_ORACLE_TABLE”是正確的語法,但是其中一列是計算出來的,因為“表”實際上是一個帶有計算列的視圖,並且底層數據的格式很差,例如呼叫文本值的數字函式。

引用自:https://dba.stackexchange.com/questions/165336