Ciao, ho fatto una funzione (di cui vi riporto qui di seguito il magro esito) per estrarre da delle stringhe con delimitatore la sottostringa composta dal maggior numero di lettere.

Mi sa che mi sono strancartatato, qualcuno riuscirebbe a darmi un aiuto?

Grazie!

-----------------------------------------------------------------------------------

mysql> DELIMITER $$
mysql>
mysql> DROP FUNCTION IF EXISTS `test`.`split` $$
set posdel = instr(tmptxt,'=');
Query OK, 0 rows affected (0.04 sec)

mysql> CREATE FUNCTION `split`( element VARCHAR (255) )
-> RETURNS varchar (255) DETERMINISTIC
-> BEGIN
->
-> DECLARE posdel INT(11);
-> DECLARE element VARCHAR(250);
-> DECLARE tmptxt VARCHAR(250);
-> DECLARE value VARCHAR(250);
->
-> set posdel = instr(tmptxt,'=');
->
-> if posdel <> 0 then
->
-> set element = substring(tmptxt, 1, posdel+1);
->
-> set value = MAX(element);
->
-> end if;
->
-> RETURN value;
->
-> END $$
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> DELIMITER ;
mysql>
mysql> select split('aaaa=999=kkjkjkjjgygfu=kkokfrh');
+-----------------------------------------+
| split('aaaa=999=kkjkjkjjgygfu=kkokfrh') |
+-----------------------------------------+
| NULL |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql>
mysql>