首页 > 解决方案 > 带有 forloop 和包含检查的 PLSQL 过程

问题描述

我尝试做的是:将 2 个信号的自定义合并过程实现为结果信号。

从 rs = s2 开始。将 SIGNAL1 中的所有自定义字段复制到 SIGNAL2 中不存在的 RESULTSIGNAL(即不存在具有相同 ID 的自定义字段)。

"custom_fields"inSIGNAL_STRUCT是 custom_fields_table 的一种类型

我的程序签名看起来像这样

 PROCEDURE signal_merge(s1 IN SIGNAL_STRUCT, s2 IN SIGNAL_STRUCT, rs OUT SIGNAL_STRUCT)

我实现这一点的伪代码是:

for custom_field : s1.custom_fields
    if(custom_field.cf_id  NOT CONTAINS IN s2.custom_fields)
       rs.custom_fields  ADD s1.custom_field

我找不到合适的语法。有人可以告诉我如何实现这一点吗?

更新:根据评论中的要求

create or replace TYPE SIGNAL_STRUCT AS OBJECT
id                        NUMBER (38),
emission_type             NUMBER(19),
custom_fields             custom_fields_table


create or replace TYPE custom_fields_struct FORCE
AS
OBJECT
(
field_id VARCHAR2 (128 CHAR),
field_value NUMBER (1)) FINAL ;

create or replace TYPE custom_fields_table FORCE
IS
  TABLE OF wf_bool_custom_fields_struct ;

更新:示例 S1 具有自定义字段

S2 有自定义字段

第一步:rs = s2 第二步:运行合并

Result:结果信号(rs)的自定义字段表,合并后必须有

标签: oracleplsqlprocedure

解决方案


推荐阅读