Good Morning. I could use some help with writing a SQL statement.
I have a process I am finishing to deal with Disabled/Deleted profiles. As a person leaves our organization the profile is added to a daily table of profiles to disable, and in a certain period after, delete.
There is a table of profiles that must be protected from deletion. Below are several protected profiles and some masked profiles. The masked profiles protect numerous profiles starting with the letters preceding the asterisk.
(iProfile)
ALL*
ARG0021105
ARV*
ARV0015501
BACKUP
BCAS*
BCASPGMR
Here is the sql statement that I need help with:
Select count(*) into :cnt from filename
where iprofile like trim(:zprofile) concat '%'
and locate('*', iprofile) <> 0;
Examples:
Profile = ‘ALLACC’ – Slq statement comes back with a count of 1, as it should.
Profile – ‘ARVBORG’ – Same as above. Works fine telling me I got a hit and should not disable the profile.
Profile – ‘BCA’ – My statement returns a count of 1, here is my issue. I want to stop at the ‘S’ in ‘BCAS’.
Is there a way for me to tell it to do the LIKE for the number of positions up to the asterisk so I do not pick up profiles that I do not want?
‘BCASAAA’ – Protected and I expect a count of 1
‘BCASB’ – Same as above’
‘BC’ – Returns me a count of 1, but I need it to stop at the ‘S’ , only profiles that contain all the letters up to the asterisk.
I hope I am clear. I could use some help.
I have a process I am finishing to deal with Disabled/Deleted profiles. As a person leaves our organization the profile is added to a daily table of profiles to disable, and in a certain period after, delete.
There is a table of profiles that must be protected from deletion. Below are several protected profiles and some masked profiles. The masked profiles protect numerous profiles starting with the letters preceding the asterisk.
(iProfile)
ALL*
ARG0021105
ARV*
ARV0015501
BACKUP
BCAS*
BCASPGMR
Here is the sql statement that I need help with:
Select count(*) into :cnt from filename
where iprofile like trim(:zprofile) concat '%'
and locate('*', iprofile) <> 0;
Examples:
Profile = ‘ALLACC’ – Slq statement comes back with a count of 1, as it should.
Profile – ‘ARVBORG’ – Same as above. Works fine telling me I got a hit and should not disable the profile.
Profile – ‘BCA’ – My statement returns a count of 1, here is my issue. I want to stop at the ‘S’ in ‘BCAS’.
Is there a way for me to tell it to do the LIKE for the number of positions up to the asterisk so I do not pick up profiles that I do not want?
‘BCASAAA’ – Protected and I expect a count of 1
‘BCASB’ – Same as above’
‘BC’ – Returns me a count of 1, but I need it to stop at the ‘S’ , only profiles that contain all the letters up to the asterisk.
I hope I am clear. I could use some help.
Comment