获取错误CallableStatementCallback;从postgreSQL调用过程时出错的SQL语法

时间:2013-05-03 16:36:34

标签: spring postgresql-9.2 postgresql-8.4

我正在使用Spring-JDBC支持和PostgreSQL并收到错误。我能够从后端运行proc。所以它是编译过程。

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 个答案:

答案 0 :(得分:1)

尝试'CREATE FUNCTION somefunc()RETURNS integer AS $$'即代替'PACKAGE'使用'FUNCTION'。使用可以检查Chapter 39. PL/pgSQL - SQL Procedural Language

您也可以检查Oracle differences between PostgreSQL's PL/pgSQL language and Oracle's PL/SQL language

之间的区别