Hi Christine,
I know you didn't want to do a lot of parsing, but this might be your best bet:
Assuming that the WHEREs you grab always follow this format:
- the LIKE clause is surrounded by ()
- the expression to the right of the LIKE always contains each character in UPPER and lower case surrounded by []
This is what you need to do:
Create a function that receives the where clause as an argument and transform it into a non-case sensitive clause.
Your function will receive this:
- WHERE (((dbo.Species.commoname like '%[Rr][Yy][Ee]%')))
and will return this:
- WHERE (((UPPER(dbo.Species.commoname) like '%RYE%')))
Here is the function code:
//**************************************************************************
// Name: of_non_case_sensitive
//
// Purpose: Transform a SYBASE specific LIKE clause into a
// generic non sensitive SQL LIKE clause
//
// Argument Type Pass By Description
// --------- ---------- --------- ----------------------------
// as_clause string value SYBASE specific LIKE clause
//
// Return Type Description
// ----------- -------------------------------------------------------
// string Generic non sensitive SQL LIKE clause
//**************************************************************************
long ll_endpos = 0, ll_begpos = 0, ll_likepos
ll_likepos = POS(UPPER(as_clause), 'LIKE')
IF ll_likepos > 0 THEN
DO
ll_endpos = POS(as_clause, ']')
IF ll_endpos > 0 THEN
as_clause = LEFT(as_clause, ll_endpos - 2) + MID(as_clause, ll_endpos + 1)
END IF
LOOP WHILE ll_endpos > 0
DO
ll_endpos = POS(as_clause, '[')
IF ll_endpos > 0 THEN
as_clause = LEFT(as_clause, ll_endpos - 1) + MID(as_clause, ll_endpos + 1)
END IF
LOOP WHILE ll_endpos > 0
ll_endpos = ll_likepos - 2
ll_begpos = ll_endpos
DO
ll_begpos --
LOOP WHILE MID(as_clause, ll_begpos, 1) <> '('
as_clause = LEFT(as_clause, ll_begpos) + 'UPPER(' + MID(as_clause, ll_begpos + 1, ll_endpos - ll_begpos) + ')' + MID(as_clause, ll_endpos + 1)
END IF
RETURN as_clause
Now you just need to call this function to transform each one of the WHEREs you grabbed.
HTH,
Manuel.