贷方通知单表
Report1
paymentModeAmount表
id invoice_id generated_at(timestamp) status
10101 111 2018-02-28 14:42:39.247 generated
23982 111 2018-03-30 11:11:11.247 generated
执行以下查询后,输出是
paymentModeAmount表
id invoice_id paid_on(timestamp) payment_mode
98236 111 creditNote
63725 111 creditNote
PaidOn列的数据相同,但是我们需要获取两个不同的时间戳
预期
id invoice_id paid_on(timestamp) payment_mode
98236 111 2018-02-28 14:42:39.247 creditNote
63725 111 2018-02-28 14:42:39.247 creditNote
paidOn时间戳记应该与预期的不同
PL / SQL函数
id invoice_id paid_on(timestamp) payment_mode
98236 111 2018-02-28 14:42:39.247 creditNote
63725 111 2018-03-30 11:11:11.247 creditNote
执行以下功能
CREATE OR REPLACE FUNCTION updatePaidOn()
RETURNS TABLE(
invoiceid BIGINT,
generatedat TIMESTAMP)
AS $$
BEGIN
RETURN QUERY SELECT
generated_invoice_id as invoiceid, generated_at as generatedat
FROM
credit_note
WHERE
status='generated';
END; $$
LANGUAGE 'plpgsql';