MySQL Forums
Forum List  »  Oracle

Re: Funcion INSTR
Posted by: Fabio Castillo
Date: August 18, 2009 04:32PM

ok, Thanks, now I understand.

I thought it was, but NO :(

The example we saw is the next and confused me

SELECT INSTR ( 'PEPE PEREZ', 'PE', 1,2) FROM DUAL;
Returns 3

But you're right, 3 refers to the position

I had done was create my own function to read the string and check for each record.

CREATE FUNCTION instrcount( cadena VARCHAR(20), SearchMyChar CHAR(1) ) RETURNS int
BEGIN
DECLARE cadenaLength int;
DECLARE posicion int;
DECLARE contador int;

SET contador = 0;
SET posicion = 1;
SET cadenaLength = LENGTH(cadena);

WHILE (posicion <= cadenaLength)
BEGIN
IF (SUBSTRING(cadena, posicion, 1) = SearchMyChar)
SET contador = contador + 1;
SET posicion = posicion + 1;
END

RETURN contador;

END

Thank you very much!

Options: ReplyQuote


Subject
Views
Written By
Posted
9370
August 16, 2009 12:00PM
6708
August 17, 2009 02:38PM
3939
August 18, 2009 10:34AM
3761
August 18, 2009 12:58PM
Re: Funcion INSTR
4098
August 18, 2009 04:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.