2013-05-03 55 views
0

我使用Spring-JDBC支持和PostgreSQL並且出現錯誤。我能夠從後端運行proc。所以它的編譯過程。獲取錯誤CallableStatementCallback;錯誤的SQL語法,同時從postgreSQL調用程序

CREATE OR REPLACE PACKAGE schemaname.my_pkg_name 
IS 
PROCEDURE update_email(person_id numeric, OUT email_gratitude_id numeric); 
END my_pkg_name; 

CREATE OR REPLACE PACKAGE BODY schemaname.my_pkg_name 
IS 
PROCEDURE update_email(person_id numeric, OUT email_gratitude_id numeric) IS 

begin 
select email_gratitude_id into email_gratitude_id from schemaname.emp_email_dtls_tbl 
where person_id=person_id; 

end; 
END my_pkg_name 

private class EmployeeSP extends StoredProcedure 
{ 
    private static final String SPROC_NAME = "schemaname.my_pkg_name.update_email"; 

    public EmployeeSP(DataSource datasource) 
    { 
     super(datasource, SPROC_NAME);      
     declareParameter(new SqlParameter("person_id", Types.INTEGER));   
     declareParameter(new SqlOutParameter("email_gratitude_id", Types.INTEGER)); 

     compile(); 
    } 

    public Object execute(int emp_id) 
    { 
     Map<String,Object> results = super.execute(emp_id,null); 
     return results.get("email_gratitude_id"); 

    } 
}; 


EmployeeSP tp = new EmployeeSP(template.getDataSource()); 
tp.execute(123456); 
 
===================================================================== 
21:31:48,386 ERROR [com.myproject.dao.EmailDAOImpl] (http--0.0.0.0-8080-6) org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call schemaname.my_pkg_name.update_email(?, ?)}]; nested exception is org.postgresql.util.PSQLException: ERROR: function schemaname.my_pkg_name.update_email(integer) does not exist 
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98) 
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) 
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1030) 
    at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1064) 
+1

甲骨文differences between PostgreSQL's PL/pgSQL language and Oracle's PL/SQL language之間的區別'CREATE OR REPLACE PACKAGE'是Oracle的聲明。這對Po​​stgres無效。請閱讀手冊。 – 2013-05-03 16:42:53

回答