-- Check if NIF Number already exists in Database when adding or updating a BP Master (ObjType 2 = Business Partners) if (:object_type = '2' and (:transaction_type='A' or :transaction_type='U')) then cnt := 0; select count(*) into cnt from "OCRD" T0 where T0."CardCode" = :list_of_cols_val_tab_del AND EXISTS (SELECT T99."CardCode" FROM "OCRD" T99 WHERE T0."LicTradNum" = T99."LicTradNum" and (T0."CardType" = T99."CardType" or (T0."CardType" = 'C' and T99."CardType" = 'L') or (T0."CardType" = 'L' and T99."CardType" = 'C')) and T0."LicTradNum" NOT LIKE '%9999999%' and T99."CardCode" <> :list_of_cols_val_tab_del); if :cnt > 0 then error := -24; error_message := CONCAT(N'This NIF-VAT Number already exists in the database. Please insert a unique NIF-VAT Number | ',:cnt); end if; end if;