Я пытаюсь вызвать функцию / хранимую процедуру PostgreSQL (которая возвращает курсор).Я вызываю функцию через stored-proc-outbound-gateway
Spring Integration.Это дает мне сообщение об ошибке ниже:
Caused by: org.springframework.messaging.MessageHandlingException: Expression evaluation failed: @sampleProcedureGateway.exchange(#root).payload; nested exception is org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call erb.getSampleDetails_sp(?, ?, ?, ?, ?)}]; SQL state [34000]; error code [0]; ERROR: cursor "<unnamed portal 5>" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 5>" does not exist
Ниже приведена моя конфигурация Spring Integration:
<int:chain input-channel="inputDataChannel">
<int-jdbc:stored-proc-outbound-gateway data-source="dataSource" expect-single-result="true" is-function="true" stored-procedure-name="erb.getSampleDetails_sp" ignore-column-meta-data="true">
<int-jdbc:sql-parameter-definition name="id" direction="IN"/>
<int-jdbc:sql-parameter-definition name="date" direction="IN"/>
<int-jdbc:sql-parameter-definition name="name" direction="IN"/>
<int-jdbc:sql-parameter-definition name="endrow" type="INTEGER" direction="IN"/>
<int-jdbc:sql-parameter-definition name="startrow" type="INTEGER" direction="IN"/>
<int-jdbc:sql-parameter-definition name="finalData" direction="OUT"/>
<int-jdbc:parameter name="id" expression="headers.messageProcessResultHeader.interfaceRequestMetaData.dealerCode"/>
<int-jdbc:parameter name="date" expression="headers['documentDate']"/>
<int-jdbc:parameter name="name" expression="headers['IsRTIDealer']"/>
<int-jdbc:parameter name="endrow" expression="headers['endRow']"/>
<int-jdbc:parameter name="startrow" expression="headers['startRow']"/>
<int-jdbc:returning-resultset name="finalData" row-mapper="sampleRowMapper" />
</int-jdbc:stored-proc-outbound-gateway>
</int:chain>
Ниже представлена хранимая процедура:
CREATE OR REPLACE FUNCTION erb.getSampleDetails_sp(
id text,
date text,
name text,
endrow double precision,
startrow double precision,
OUT finalData refcursor)
RETURNS refcursor
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$
BEGIN
IF name = 'true' THEN
OPEN finalData FOR
SELECT
*
FROM (SELECT
row_number() OVER (ORDER BY NULL) AS rnum, vhinv.*
FROM (SELECT query) AS vhinv
LIMIT i_endrow) AS var_sbq
WHERE rnum >= i_startrow;
ELSE
OPEN finalData FOR
SELECT
*
FROM (SELECT
row_number() OVER (ORDER BY NULL) AS rnum, vhinv.*
FROM (SELECT query) AS vhinv
LIMIT i_endrow) AS var_sbq_2
WHERE rnum >= i_startrow;
END IF;
END;
$BODY$;
Есть ли способрешить эту проблему?