我们最近切换到使用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);
我似乎无法以任何方式找到与此错误相关的任何信息。为什么上述代码会出现此错误?
答案 0 :(得分:1)
我能够通过将语法从? = call...
语法切换到select * from receive_item...