2012-11-23 18 views
2

我在Windows Xp 32Bit上運行的Oracle 11 Express安裝中遇到問題。ORA-00911在評論中使用雙連字符時出錯

當我通過Ant運行SQL腳本時,每次使用雙連字符時都會引發Ora-00911錯誤。當我在Unix上的Oracle安裝上運行完全相同的代碼時,它就像一個魅力。

這是我的查詢:

comment on table X.TABLE is 'Commenttest -- Testingtable'; 

是否有必須適應任何配置?在我看來,有一種語法檢查認爲在評論文本中有一個SQL-Comment。

任何想法是什麼導致此錯誤?

+2

我認爲這是Ant中的一個錯誤:https://issues.apache.org/bugzilla/show_bug.cgi?id=43413所以你可能想嘗試'keepformat =「true」'btw:+1 for使用數據庫評論! –

+0

這可能是螞蟻的問題 看到這個職位http://stackoverflow.com/questions/12469496/ant-sql-insert-statement-fails-on-strings-workaround –

+0

感謝,keepformat =「真」解決了問題! – Eyeless

回答

3

這是一個螞蟻蟲:https://issues.apache.org/bugzilla/show_bug.cgi?id=43413

您需要在sql任務中包含屬性 keepformat="true"
<sql driver="oracle.jdbc.OracleDriver" 
    url="jdbc:oracle:thin....." 
    userid="scott" 
    password="tiger" 
    keepformat="true"> 

    comment on table foo is 'Commenttest -- Testingtable'; 
</sql> 
+0

就是這樣! keepformat =「true」解決了問題! – Eyeless

2

它看起來像你缺少右單引號:

comment on table X.TABLE is 'Commenttest -- Testingtable'; 
                 ^----add this single quote 
+0

對不起,我的錯,遺漏的單引號是複製錯誤。我在發言中有這個意見,我糾正了我原來的帖子。 – Eyeless

1

你缺少終端報價,請添加如下:

 comment on table X.TABLE is 'Commenttest -- Testingtable'; 
+0

對不起,我的錯,缺少的單引號是複製錯誤。我在發言中有這個意見,我糾正了我原來的帖子。 – Eyeless

+0

@Eyeless你是否嘗試在連字符前使用轉義字符'\'? –