2015-09-16 71 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