Created
June 20, 2012 16:29
-
-
Save marcomarkkez/2960790 to your computer and use it in GitHub Desktop.
ejemplo de store procedure dinamica en mysql para insertar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
DROP PROCEDURE IF EXISTS Insertar $$ | |
CREATE PROCEDURE Insertar( | |
IN tipo INT, | |
IN tablas VARCHAR(1000), | |
IN columnas VARCHAR(1000), | |
IN inserciones VARCHAR(1000) | |
) | |
BEGIN | |
IF (tipo IS NULL) THEN | |
-- testeado con el siguiente query | |
-- CALL db.Insertar(NULL, "acceso", "FK_Persona, Usuario, Password, UltimoInicioSesion, Status", "13,'marquez','marquezpass','02:30', 'bueno'") | |
SET @consultatext = CONCAT( "INSERT INTO ",tablas, " (", columnas, ") VALUES (", inserciones, ");" ); | |
PREPARE insertar FROM @consultatext; | |
EXECUTE insertar; | |
END IF; | |
END $$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment