Det visade sig vara ett fall av dålig data. Datat i min test-DB var korrupt och hade bara LF i stället för CRLF.
GIGO :-)
Tack för all hjälp
Och förresten, i mitt kodexempel gick jag med INSTR-funktionen i stället för like-funktionen. Om användaren angav en % i texten att söka igenom kunde det ha stört lik-satsen. (Kan inte filtrera bort dem eftersom % kan vara ett giltigt tecken i min data)
Här är den slutliga koden:
PROCEDURE FindReplaceResponsibilities ( iOldResponsibilities IN JP_JOB_FAMILIES.RESPONSIBILITIES%TYPE, iNewResponsibilities IN JP_JOB_FAMILIES.RESPONSIBILITIES%TYPE, oNumRowsUpdated OUT INTEGER ) IS
BEGIN oNumRowsUpdated := 0;
SAVEPOINT sp_jf_findrepresp; -- If there is no old text to search for then, -- append the new text to the end of every row. -- Else replace all occurrences of the old text with the new text IF iOldResponsibilities IS NULL THEN UPDATE JP_JOB_FAMILIES SET RESPONSIBILITIES = RESPONSIBILITIES || iNewResponsibilities; oNumRowsUpdated := SQL%ROWCOUNT; ELSE UPDATE JP_JOB_FAMILIES SET RESPONSIBILITIES = REPLACE(RESPONSIBILITIES, iOldResponsibilities, iNewResponsibilities) WHERE dbms_lob.instr(RESPONSIBILITIES, iOldResponsibilities) > 0; oNumRowsUpdated := SQL%ROWCOUNT; END IF; RETURN; EXCEPTION WHEN OTHERS THEN BEGIN oNumRowsUpdated := -1; ROLLBACK TO sp_jf_findrepresp; dbms_output.put_line('error: ' || sqlerrm); RETURN; END; END FindReplaceResponsibilities;
Koden från min applikation var bra:
public int FindReplaceJobFamilyResponsibilities(String oldResponsibilities, String newResponsibilities, IDbTransaction transaction = null) { using (IDbCommand cmd = this._dataHelper.GetStoredProcedure(_connectionString, "JP_JOBFAM_PKG.FindReplaceResponsibilities", true)) { _dataHelper.SetParameterValue(cmd, "iOldResponsibilities", oldResponsibilities); _dataHelper.SetParameterValue(cmd, "iNewResponsibilities", newResponsibilities); DataHelperBase.VerifyParameters(cmd.Parameters, false); base.SetExecuteConnection(cmd, transaction); _dataHelper.ExecuteNonQuery(cmd); return Convert.ToInt32(_dataHelper.GetParameterValue(cmd, "oNumRowsUpdated")); } } Användning av DBMS_LOB.INSTR i stället för LIKE gör sökningen robust även när indata innehåller jokertecken.