我目前正在尝试更新 SQR 以检查给定记录中跨列的重复值。我们允许将重复项输入到表中,但我们希望检查一个错误标志,因为它会破坏下一个程序。
ID - 1 Var1 - 3809 Var2 - 3809
ID - 2 Var1 - NULL Var2 - NULL
ID - 3 Var1 - 5204 Var2 - 3809
在这种情况下,ID 1 会检查错误标志,而其他两个则不会。我不能简单地检查值,因为我需要检查 12 个不同的列。任何帮助将非常感激。
谢谢!担
我尝试了下面的代码,它可以编译,但不记录重复项
begin-procedure check-duplicates
create-array name=SchlDuplicates
size=15
Field=Val:Char
BEGIN-SQL
SELECT
MICA_SCH1_CEEBCD
MICA_SCH2_CEEBCD
MICA_SCH3_CEEBCD
MICA_SCH4_CEEBCD
MICA_COL1_CEEBCD
MICA_COL2_CEEBCD
MICA_COL3_CEEBCD
MICA_TRSCH1_CEEBCD
MICA_TRCOL1_CEEBCD
MICA_TRCOL2_CEEBCD
MICA_TRCOL3_CEEBCD
MICA_TSSCH1_CEEBCD
MICA_TSSCH2_CEEBCD
MICA_TSSCH3_CEEBCD
put MICA_SCH1_CEEBCD into SchlDuplicates(1) Val
put MICA_SCH2_CEEBCD into SchlDuplicates(2) Val
put MICA_SCH3_CEEBCD into SchlDuplicates(3) Val
put MICA_SCH4_CEEBCD into SchlDuplicates(4) Val
put MICA_COL1_CEEBCD into SchlDuplicates(5) Val
put MICA_COL2_CEEBCD into SchlDuplicates(6) Val
put MICA_COL3_CEEBCD into SchlDuplicates(7) Val
put MICA_TRSCH1_CEEBCD into SchlDuplicates(8) Val
put MICA_TRCOL1_CEEBCD into SchlDuplicates(9) Val
put MICA_TRCOL2_CEEBCD into SchlDuplicates(10) Val
put MICA_TRCOL3_CEEBCD into SchlDuplicates(11) Val
put MICA_TSSCH1_CEEBCD into SchlDuplicates(12) Val
put MICA_TSSCH2_CEEBCD into SchlDuplicates(13) Val
put MICA_TSSCH3_CEEBCD into SchlDuplicates(14) Val
Let #I = 1
Let $DupFound = 'N'
While #I <= 13 and $DupFound = 'N'
Let #J = #I + 1
While #J <= 14
Get $Val1 from SchlDuplicates(#I) Val
Get $Val2 from SchlDuplicates(#J) Val
If $Val1 = $Val2
let $DupFound = 'Y'
do Insert-Error
End-If
add 1 to #J
End-While
Add 1 to #I
End-While
FROM PS_MICA_STSCHL_STG
WHERE MICA_COMMON_APP_ID = $Application_ID || $Val1
END-SQL
End-Procedure
Begin-Procedure Insert-Error
If $DupFound = 'Y'
Let $Error_table = 'Duplicate Schools'
End-If
BEGIN-SQL
INSERT INTO PS_MICA_ERROR_LOG
VALUES($Application_ID,
$App_export_dt,
$Error_table,
'')
END-SQL
end-procedure