--定義行類型
CREATE TYPE ROW_TYPE AS OBJECT(
CONTRACT_NO VARCHAR2(30),
SEND_RECEIVE VARCHAR2(20),
API_URL VARCHAR2(100),
SEND_CONTENT CLOB,
RECEIVE_CONTENT CLOB,
LOG_INFO CLOB,
CREATE_TIME DATE,
ID_CARD VARCHAR2(30),
SEARCH_KEY VARCHAR2(200)
);
--定義結果集類型
CREATE TYPE TABLE_TYPE AS TABLE OF ROW_TYPE;函數
--根據合同號查詢日誌函數
CREATE OR REPLACE FUNCTION queryLogByContractNo(contractNo IN VARCHAR2) RETURN TABLE_TYPE PIPELINED AS
V ROW_TYPE;
BEGIN
FOR MYROW IN (
SELECT
CONTRACT_NO,SEND_RECEIVE,API_URL,SEND_CONTENT,RECEIVE_CONTENT,
LOG_INFO,CREATE_TIME,ID_CARD,SEARCH_KEY
FROM LOANAUDITUSER.ZHPH_INTEGERFACE_LOG WHERE CONTRACT_NO = contractNo
ORDER BY CREATE_TIME DESC
)
LOOP日誌
V := ROW_TYPE(MYROW.CONTRACT_NO, MYROW.SEND_RECEIVE,MYROW.API_URL,MYROW.SEND_CONTENT,MYROW.RECEIVE_CONTENT,MYROW.LOG_INFO,
MYROW.CREATE_TIME,MYROW.ID_CARD,MYROW.SEARCH_KEY);
pipe row (V);
END LOOP;
RETURN;
END;ip
--使用方法pip
select * from table(queryLogByContractNo('91015160842729633983'));table