Advertisement
gmendezm

asociarUsuarioProyecto

May 28th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.49 KB | None | 0 0
  1. GO
  2. -- DROP PROCEDURE insertarEntrega
  3. CREATE PROCEDURE asociarUsuarioProyecto (
  4.     @idUsuario INT
  5.     , @idProyecto INT
  6. )
  7. AS
  8.     DECLARE @error TINYINT
  9.     SET @error = 0
  10.  
  11.     BEGIN TRANSACTION
  12.    
  13.     INSERT INTO usuarios_proyectos(idUsuario, idProyecto)VALUES (@idUsuario, @idUsuario)
  14.  
  15.     IF @@ERROR > 0 SET @error = 1
  16.    
  17.     IF @error = 1
  18.         BEGIN
  19.             ROLLBACK TRAN -- DESHAGA LA TRANSACCION
  20.             PRINT('Error asociando el usuario con el proyecto')
  21.         END
  22.     ELSE
  23.         COMMIT TRAN -- FINALICE LA TRANSACCION
  24. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement