偏移量5处格式错误的函数或过程转义语法

时间:2018-09-22 13:48:50

标签: java postgresql

我收到此错误“偏移量5处格式错误的函数或过程转义语法”。当我运行以下代码时:

public void callPro(int id) {
        int inv_id = id;
        int cust_id = 0;
        try {
            Connection conn = connect();
            CallableStatement cstmt = conn.prepareCall("{? = inventory_held_by_customer(?)}");
            cstmt.setInt(2, inv_id);
            cstmt.registerOutParameter(1, Types.INTEGER);
            cstmt.execute();
            cust_id = cstmt.getInt(1);
            System.out.println(cust_id);
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }

有任何解决错误的建议吗?

1 个答案:

答案 0 :(得分:0)

找到了解决方法,我在prepareCall的语句中错过了“ call”关键字:CallableStatement cstmt = conn.prepareCall(“ {?=调用stocker_held_by_customer(?)}”);