假设我有两个表,payments_received 和 payment_processed。我想在 PL/SQL 中声明一个变量以将数据从一个表复制到另一个表。两个表都有一个包含相同值的字段,例如 payor_name。我使用哪个表来定义 %TYPE、“from”或“to”?
PROCEDURE some_proc AS
-- value coming FROM payments_received
-- value going TO payments_processed
v_payor_name payments_received.payor_name%TYPE;
-- OR
v_payor_name payments_processed.payor_name%TYPE;
BEGIN
SELECT payor_name INTO v_payor_name
FROM payments_received
WHERE payment_id = some_payment_id;
UPDATE payments_processed
SET payor_name = v_payor_name
WHERE processed_id = some_processed_id;
END some_proc;
我四处寻找一些最佳实践指南,但没有找到任何真正涵盖 %TYPE/%ROWTYPE 使用方面的内容。