VbzCart/docs/coding/integrity checks: Difference between revisions
Jump to navigation
Jump to search
imported>Woozle (Created page with "Table-specific checks: * {{l/vc/table|cat_items/integrity checks}} ==Cross-table checks== Package lines and order lines which don't agree about what ID_Item they're tracking:...") |
imported>Woozle (another ol-pl cross-check) |
||
Line 2: | Line 2: | ||
* {{l/vc/table|cat_items/integrity checks}} | * {{l/vc/table|cat_items/integrity checks}} | ||
==Cross-table checks== | ==Cross-table checks== | ||
Package | Package Lines and Order Lines which don't agree about what ID_Item they're tracking: | ||
<mysql>SELECT | <mysql>SELECT | ||
* | * | ||
Line 11: | Line 11: | ||
WHERE | WHERE | ||
ol.ID_Item != pl.ID_Item</mysql> | ol.ID_Item != pl.ID_Item</mysql> | ||
Package lines whose Order Line is either not set or nonexistent(!): | |||
<mysql>SELECT | |||
pl.* | |||
FROM | |||
ord_pkg_lines AS pl | |||
LEFT JOIN | |||
ord_lines AS ol ON pl.ID_OrdLine = ol.ID | |||
WHERE | |||
ol.ID IS NULL</mysql> |
Revision as of 01:45, 7 March 2016
Table-specific checks:
Cross-table checks
Package Lines and Order Lines which don't agree about what ID_Item they're tracking: <mysql>SELECT
*
FROM
ord_pkg_lines AS pl JOIN ord_lines AS ol ON pl.ID_OrdLine = ol.ID
WHERE
ol.ID_Item != pl.ID_Item</mysql>
Package lines whose Order Line is either not set or nonexistent(!): <mysql>SELECT
pl.*
FROM
ord_pkg_lines AS pl LEFT JOIN ord_lines AS ol ON pl.ID_OrdLine = ol.ID
WHERE
ol.ID IS NULL</mysql>