feat: refs #8057 Added geoFk columns #3204

Merged
guillermo merged 10 commits from 8057-geoFk into dev 2024-11-18 11:47:54 +00:00
3 changed files with 9 additions and 6 deletions
Showing only changes of commit 353ca659cd - Show all commits

View File

@ -14,9 +14,10 @@ BEGIN
SELECT p.geoFk INTO vGeoFk
FROM address a
JOIN town t ON t.provinceFk = a.provinceFk
JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
JOIN postCode p ON p.townFk = t.id
WHERE a.id = vSelf
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
ORDER BY (a.city SOUNDS LIKE t.name) DESC,
(p.code = a.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;

View File

@ -15,9 +15,9 @@ BEGIN
FROM client c
JOIN town t ON t.provinceFk = c.provinceFk
JOIN postCode p ON p.townFk = t.id
AND p.`code` = c.postcode
WHERE c.id = vSelf
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC
ORDER BY (c.city SOUNDS LIKE t.name) DESC,
(p.code = c.postcode) DESC
guillermo marked this conversation as resolved Outdated
Outdated
Review

Puede ser que el cliente no tenga codigo postal. Yo pondria, en lugar de

AND p.code = c.postcode

en el order by pondria

ORDER BY (c.city SOUNDS LIKE t.name) DESC, (p.code = c.postcode) DESC

Puede ser que el cliente no tenga codigo postal. Yo pondria, en lugar de AND p.`code` = c.postcode en el order by pondria ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, (p.`code` = c.postcode) DESC
LIMIT 1;
RETURN vGeoFk;

View File

@ -15,9 +15,11 @@ BEGIN
FROM supplier s
JOIN town t ON t.provinceFk = s.provinceFk
JOIN postCode p ON p.townFk = t.id
AND p.`code` = s.postCode
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
guillermo marked this conversation as resolved Outdated
Outdated
Review

Lo mismo que el caso anterior. Hay 1637 proveedores sin codigo postal

Lo mismo que el caso anterior. Hay 1637 proveedores sin codigo postal
WHERE s.id = vSelf
ORDER BY (s.city SOUNDS LIKE t.`name`) DESC
ORDER BY (s.city SOUNDS LIKE t.name) DESC,
(p.code = s.postCode) DESC,
(p.code = sad.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;