
MSSQL tables link for loop sub-procedure anomaly
MSSQL tables link for loop sub-procedure anomaly
With native DE tables the following example procedure scenario always works:
--Table 1 contains 100 records
--Table 2 contains > 1 records related to Table 1 on Field: ItemID
For Table1 ;
temp tC := temp tC + 1 .
global gItemID := ItemID .
run procedure T2query .
end
message concat("Records = ", temp tC) window .
-- Sub procedure: T2query
For Table2 with ItemID = global gItemID ;
--do anything
end
--result
Records: 100
======
If Table1 & Table2 are instead MS SQL Database link tables and both on the same Database Link and contain the same records then:
--result: Records = 2
--No error reported and no crash -- without the count check there is no indication of an issue
The sub-procedure where another table on same Database link is queried prevents all records in Table1 from being processed.
If the sub-procedure query is for another native DE table then there is no issue: -> Records = 100
What does work for the MS SQL tables:
1. Tables are both on MS SQL and on the same database link and query is changed to not have a sub-procedure.
For Table1 ;
temp tC := temp tC + 1 .
global gItemID := ItemID .
For Table2 with ItemID = global gItemID ;
--do anything
end
end
message concat("Records: ", temp tC) window .
--result
Records = 100
=======
2. Tables are still both on MS SQL and each is on a different database link (even if the source of the tables are the same) - just different DB link names on DE
Sub-procedure construct given above works as expected. -> Records = 100
In summary:
MS SQL link table for loop query procedures with sub-procedures including queries to any tables on the same Database link do not work as expected and do not report any errors.
This has been confirmed to occur on LegEasy 6.53 and DE 8.5
Not tested on LE9 although likely to also occur.