I have a field ERR_CODES
on my db that contains some error codes for the current record.
For example, it can contain:
Invalid_Template_Code_Filename_WCLS,Color_Template_Of_Different_Domain_WCLS,Section_Not_Found_WCLS
Suppose I want to test if it contains Section_Not_Found_WCLS
, without adding a comma at the start and at the end of the field.
I should test for:
WHERE "ERR_CODES" LIKE '%,Section_Not_Found_WCLS,%' --between other errs
OR "ERR_CODES" LIKE 'Section_Not_Found_WCLS,%' --at start of a err sequence
OR "ERR_CODES" LIKE '%,Section_Not_Found_WCLS' --at end of a err sequence
OR "ERR_CODES" = 'Section_Not_Found_WCLS' --unique err for this record
This is not really beautiful.
Is there a way to compact that, using wildcards?
EDIT:
In RegEx this would be ((?<=,)|^)Section_Not_Found_WCLS((?=,)|$)
Ideally, I want a solution that will work on each of Oracle, MSSQL, PGSQL.