Hi made a function that modifies a little bit the INSTR function (Oracle SQL): instead of getting '0' when a space char isn't found, I get the length of the string.
It compiles but when I try to execute it, i'm getting the ORA-06550 error (which is, if i'm not wrong, a compilation error).
I tried this function as a procedure and it runs all right... so I don't understand why it doesn't want to execute.
Can you help me?
CREATE OR REPLACE FUNCTION "INSTR2" (str varchar2) RETURN NUMBER AS
pos number(4,0) := 0;
BEGIN
select INSTR(str, ' ') into pos from dual;
if (pos = 0) then
select to_number(length(str)) into pos from dual;
return pos;
else
return pos;
end if;
END INSTR2;
Thanks a lot,
R.L.
Well, there is already a built-in function called
INSTR2in Oracle (look, here it is).I've just compiled your function with another name and it worked. So the code is valid, you just have to pick the name for it.
Apparently Oracle resolves
INSTR2to the built-in function despite the fact you now have the function with such name in your own schema (I couldn't find the reason for it in docs, but this behaviour is not exactly surprising). AndINSTR2expects more parameters than your implementation. That causes a runtime error.