Skip navigation links

MySQL Forums :: Spanish :: Store procedure


Advanced Search

Store procedure
Posted by: claudio claudio ()
Date: March 28, 2012 11:11AM

Hola a todos,
perdonate mi ignorancia,
no logro convertir un "Store procedure" de MS SQL 2000 a MySql:
se alquien me da una manita lo agradezco infinitamente y tengo la
`posibilidad de veer come se resolvio:
//////////////////// MS Sql 2000 /////////////
DELIMITER $$

DROP PROCEDURE IF EXISTS `millenium1`.`AddOpcionesNuevas` $$
CREATE PROCEDURE `XXXXX`.`Nuevas` ()
BEGIN

DECLARE @IdUsuario int
DECLARE @IdOpcion int
DECLARE Usuarios CURSOR FOR Select idUsuario from usuarios

DECLARE OpcionesNuevas SCROLL CURSOR FOR Select idOpcion from opciones where idopcion not in (select distinct idOpcion from Opcion)

Open Usuarios
Open OpcionesNuevas

FETCH NEXT FROM usuarios into @IdUsuario
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH first FROM OpcionesNuevas into @IdOpcion
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO opcionusuario([idUsuario], [idOpcion], [Acceso], [Alta], [Baja], [Modificacion], [Consulta], [Excel], [Estadisticas], [Documentos], [Correo] ) VALUES(@idUsuario, @idOpcion, 1, 1,1,1,1,1,1,1,1)
FETCH NEXT FROM OpcionesNuevas into @IdOpcion
END
FETCH NEXT FROM Usuarios into @IdUsuario
END


Close Usuarios
Close OpcionesNuevas

Deallocate Usuarios
Deallocate OpcionesNuevas





GO

END $$

DELIMITER ;/////////////////////////
Un saludo
Claudio

Options: ReplyQuote


Subject Views Written By Posted
Store procedure 1050 claudio claudio 03/28/2012 11: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.