postgresql中的记录变量需要动态传递

时间:2018-03-28 20:31:38

标签: postgresql postgresql-9.3

我在从记录变量中取值以用作要插入的表时遇到问题。

DECLARE
   validation_table record;
   mirror_table record;
BEGIN
   FOR validation_table IN  
      select validationrule,businesscolumnname,businesstablename 
      from ipte_cds.error_validation_rule
      group by validationrule,businesscolumnname,schemaname
   LOOP
      For mirror_table in 
         select src_sys_id from validation_table.businesstablename
         where validation_table.businesscolumnname is null
      LOOP
         insert into ipte_cds.mac_error_event_log
            businesscolumnname,
            businesstablename,
            validationrule,
            src_sys_id
         select
            validation_table.businesscolumnname,
            validation_table.businesstablename,
            validation_table.validationrule,
            mirror_table.src_sys_id
         from validation_table, mirror_table;
      END LOOP;
   END LOOP;
END;

0 个答案:

没有答案