chandu_jagtap 0 Newbie Poster

i had created a function which convert the string in Proper case but i want to modify all the records in a particular table by just providing the table name to the function so the function/procedure will have to update all the records in proper case, in record by record fashion.

i am providing the script for the same.

DROP PROCEDURE IF EXISTS CORE_logic;
DELIMITER |

CREATE PROCEDURE CORE_logic(PLAIN_Text VARCHAR(15))
 BEGIN

  DECLARE c CHAR(1);
  DECLARE Result_s VARCHAR(15);
  DECLARE i INT DEFAULT 1;
  DECLARE bool INT DEFAULT 1;
  DECLARE punct CHAR(17) DEFAULT ' ()[]{},.-_!@;:?/';


  SET Result_s = LCASE( PLAIN_TEXT );
  WHILE i < LENGTH( PLAIN_TEXT ) DO 
    BEGIN
    SET c = SUBSTRING( Result_s, i, 1 );
            IF LOCATE( c, punct ) > 0 THEN
        SET bool = 1;
            ELSEIF bool=1 THEN 
                BEGIN
                    IF c >= 'a' AND c <= 'z' THEN 
                        BEGIN
                            SET Result_s = CONCAT(LEFT(Result_s,i-1),UCASE(c),SUBSTRING(Result_s,i+1));
                                SET bool = 0;
                                END;
                            ELSEIF c >= '0' AND c <= '9' THEN
                            SET bool = 0;
                        END IF;
                    END;
            END IF;
            SET i = i+1;

    END ;

  END WHILE;
     SELECT RESULT_s;
  END;
|
DELIMITER ;

call core_logic('CHAN11THa))@NT');

this is the core logic of my function.

for doing same to database i have to use cursor but i dose not work for me.

can any one help me to sort out this thing....

thank you.