2015-09-16 150 views
0

我正在調用Java應用程序中的PL/SQL過程來更新數據庫條目。通過Java代碼調用Oracle存儲過程時出錯

Connection connection = null; 
CallableStatement preparedCall = null; 
Integer result = 0; 
preparedCall = connection.prepareCall("{ call ? := pkg_temp.update_data(?, ?)}"); 
preparedCall.registerOutParameter(1, OracleTypes.INTEGER); 
preparedCall.setString(2, variable1); 
preparedCall.setString(3, cariable2); 
result = preparedCall.executeUpdate(); 

但我在executeUpdate的提示以下錯誤:()

Caused by: java.sql.SQLException: ORA-06550: line 1, column 11: 
PLS-00103: Encountered the symbol "=" when expecting one of the following: 
:= . (@ % ; indicator 
ORA-06550: line 1, column 51: 
PLS-00103: Encountered the symbol ";" when expecting one of the following: 
. () , * % & - +/at mod remainder rem <an exponent (**)> 
and or || multiset 

我在哪裏做錯了嗎?

回答

0

:=是錯誤的,用於返回參數佔位符必須上市前call關鍵字(as documented in the JavaDocs):

connection.prepareCall("{?= call pkg_temp.update_data(?, ?)}"); 
+0

感謝suggettion。但是改爲這種語法會導致此錯誤嚴重:java.sql.SQLException:ORA-06550:第1行第13列: PLS-00382:表達式類型錯誤 ORA-06550:第1行第7列: PL/SQL:語句被忽略 – shaaa

+0

那麼,這是一個錯誤_inside_您的存儲過程。您要麼傳遞錯誤的類型,要麼您的過程依賴於邪惡的隱式數據類型轉換。在任何一種情況下,如果沒有看到程序 –

+0

的完整代碼,則無法回答......我想我發現了這個問題。我的過程的返回類型是布爾值。但是我在這裏註冊Integer。但是,將out參數註冊到OracleTypes.BOOLEAN將不起作用。我該怎麼做? – shaaa