Solved

# ORACLE 11 g - Construct a comma delimited string with single quotes to insert into a table

Posted on 2011-09-29

I would like to be able to take the min and max pay grade and construct and string for the IN clause to use as a search range.

For example I have to find all personnel whose pay grade is between E-1 and E-3 that would include those who have E-1, E-2, E-3 paygrade.

The min and max are values in a table but I need to derive a search range.

min max search range

E-1 E-2 'E-1','E-2'

E-1 E-3 'E'-1','E-2','E-3'

E-1 E-4 'E'-1','E-2','E-3','E-4'

E-1 E-10 'E'-1','E-2','E-3','E-4','E-5','E-6','E-7','E-8','E-9','E-10'