运行 来自 java 的 postgresql 函数时出错

Error when running postgresql function from java

我们最近切换到使用 postgresql (enterpriseDB),并且我移动了一个函数但是当我 运行 它时我得到:

com.edb.util.PSQLException: ERROR: bind message has 2 result formats but query has 1 columns

函数是:

CREATE OR REPLACE FUNCTION receive_item(qtyexpected integer, qtyrcvd integer, reasoncd character varying, commenttext character varying, whs character varying, rcvrnbr character varying, ponbr character varying, itemid character varying) RETURNS integer AS
$BODY$
  rcvrDtlId integer;  
begin
  rcvrDtlId := 0;

  begin
    update rcvr_dtl set 
    qty_expected = qtyExpected, qty_received = qty_received + qtyRcvd, reason_cd = reasonCd, comments = commentText 
    where warehouse = whs and rcvr_nbr = rcvrNbr and po_nbr = poNbr and item_nbr = itemId
    returning rcvr_dtl_id into rcvrDtlId;                             
  exception
     when no_data_found then
        null;
  end;                              

  return rcvrDtlId;
end$BODY$
LANGUAGE edbspl VOLATILE NOT LEAKPROOF
COST 100;

它被调用:

sql= "{? = CALL receive_item(?,?,?,?,?,?,?,?)}";
m_ReceiveItem = m_Conn.prepareCall(sql);
m_ReceiveItem.registerOutParameter(1, Types.INTEGER);
m_ReceiveItem.setInt(2, msg.getQtyExpected());
m_ReceiveItem.setInt(3, msg.getQtyReceived());
m_ReceiveItem.setString(4, msg.getReasonCode());
m_ReceiveItem.setString(5, msg.getComments());
m_ReceiveItem.setString(6, msg.getFacilityNbr());
m_ReceiveItem.setString(7, msg.getRcvrNbr());
m_ReceiveItem.setString(8, msg.getPoNbr());
m_ReceiveItem.setString(9, msg.getSku());
m_ReceiveItem.execute();
rcvrDtlId = m_ReceiveItem.getInt(1);

我似乎找不到与此错误相关的任何信息。为什么上面的代码会出现这个错误?

我能够通过将语法从 ? = call... 语法切换到 select * from receive_item...

来解决这个问题