Subject LIKE operator inside stored procedure
Author zdeseb
Hello,
I have stored procedure with VARCHAR parameter. And I have table
PATHS with indexed column PATH_VALUE (VARCHAR).

Inside procedure is following statement

UPDATE PATHS
SET PATH_DELETION = NULL
WHERE PATH_VALUE LIKE :PARAMETER;

Now I call this procedure

EXECUTE PROCEDURE NAME('\\path\hsjha\%');

index is not used and table PATHS is sequentialy readed.

If I execute statement directly

UPDATE PATHS
SET PATH_DELETION = NULL
WHERE PATH_VALUE LIKE '\\path\hsjha\%';

index is used and performance is much better.

Is there any way how to write stored procedure which use LIKE
operator with parameter/variable on the right site? And of course
without horrible performance degradation described above?

Thanks,
Zdenek