MySQL Forums
Forum List  »  Italian

query e function
Posted by: marco pilolli
Date: October 18, 2007 04:11AM

ho la seguente query che funziona:

SELECT Conto
FROM gldplancodedetail
JOIN glsdettagliomenufield AS XX ON XX.RecId=gldplancodedetail.TipoConto
WHERE cast(gldplancodedetail.Conto as unsigned) > cast('3000' as unsigned) AND XX.vocemenu='Di Riepilogo'
AND refglsbalanceplangestion=(SELECT refglsbalanceplangestion FROM gldcategorysectorplanaccount WHERE taglevel='1.1.5') AND NOT (gldplancodedetail.visibility=1)
order by cast(Conto as unsigned)
limit 0,1

e funziona e mi ritorna il conto di riepilogo successivo
ma se questo lo metto in una funzione per richiamarlo
mi da altri risultati
ecco la funzione che ho scritto

DELIMITER $$

DROP FUNCTION IF EXISTS `xxxx`.`filtrosaldiconti`$$

CREATE DEFINER=`root`@`%` FUNCTION `filtrosaldiconti`(visconto varchar(10), parid varchar(30)) RETURNS varchar(10) CHARSET latin1
BEGIN
SET @tornocosa = ' ';
SELECT Conto INTO @tornocosa
FROM gldplancodedetail
LEFT JOIN glsdettagliomenufield AS XX ON XX.RecId=gldplancodedetail.TipoConto
WHERE cast(gldplancodedetail.Conto as unsigned) > cast(visconto as unsigned) AND XX.vocemenu='Di Riepilogo'
AND refglsbalanceplangestion=(SELECT refglsbalanceplangestion FROM gldcategorysectorplanaccount WHERE taglevel=parid) AND NOT (gldplancodedetail.visibility=1)
ORDER BY Conto
LIMIT 1 ;
RETURN @tornocosa;
END$$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
query e function
3857
October 18, 2007 04:11AM


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.