Re: Valor devuelto FUNCTION
Hola XaVieRi,
El siguiente código quizás te pueda ayudar:
DROP TABLE IF EXISTS `mytabla`;
CREATE TABLE `mytabla` (
`id` int(11) NOT NULL auto_increment,
`fecha` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DELIMITER $$
DROP FUNCTION IF EXISTS `myfuncion`$$
CREATE FUNCTION `myfuncion`()
RETURNS INT
BEGIN
INSERT INTO mytabla (fecha) VALUES (NOW());
RETURN LAST_INSERT_ID();
END$$
DELIMITER ;
SELECT myfuncion();
Result:
myfuncion()
-----------
1
SELECT * FROM mytabla;
Result:
id fecha
------ -------------------
1 2007-06-01 08:12:22
SELECT myfuncion();
Result:
myfuncion()
-----------
2
SELECT * FROM mytabla;
Result:
id fecha
------ -------------------
2 2007-06-01 08:12:23
Subject
Views
Written By
Posted
5526
June 07, 2007 09:38AM
Re: Valor devuelto FUNCTION
2401
June 07, 2007 01:33PM
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.