-- pre_deploy_verify_soundex.sql
-- Rulat pe production Oracle INAINTE de deploy 05_pack_import_parteneri.pck (fix SOUNDEX L2)
-- Verifica ca premisa e adevarata: "Crampoaia/Crimpoia" exista in nomenclator pentru OLT

SELECT l.localitate,
       SOUNDEX(CONVERT(UPPER(TRIM(l.localitate)), 'US7ASCII', 'AL32UTF8')) soundex_val
FROM syn_nom_localitati l
JOIN syn_nom_judete j ON l.id_judet = j.id_judet
WHERE j.judet = 'OLT' AND j.sters = 0
  AND SOUNDEX(CONVERT(UPPER(TRIM(l.localitate)), 'US7ASCII', 'AL32UTF8')) = SOUNDEX('CRAMPOIA')
  AND l.inactiv = 0 AND l.sters = 0;
-- Rezultat asteptat: >=1 row (ex: CRIMPOIA cu SOUNDEX C651)
-- Daca 0 rows: Crampoaia nu exista in nomenclator → SOUNDEX nu rezolva → alt plan necesar
