Advertisement
gmendezm

Insertar asada con su teléfono

May 14th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.71 KB | None | 0 0
  1. /***Transaccion Insertar Asada Con su telefono****/
  2. GO
  3. CREATE PROCEDURE insertAsadas(@nombre VARCHAR(30), @direccion tipo_direccion, @numero tipo_telefono)
  4. AS
  5.     DECLARE @idAsada    SMALLINT,
  6.             @error        SMALLINT
  7.     SET @idAsada  = 0
  8.     SET @error = 0
  9. BEGIN TRANSACTION
  10.     INSERT INTO asadas(nombre, direccion) VALUES (@nombre, @direccion)
  11.     IF @@ERROR > 0
  12.             SET @error = 1
  13.  
  14.     SET @idAsada = @@IDENTITY
  15.     INSERT INTO telefonos_asadas(idAsada, numero) VALUES (@idAsada, @numero)
  16.     IF @@ERROR > 0
  17.         SET @error = 1
  18.     IF @error = 1
  19.         BEGIN
  20.             ROLLBACK tran
  21.             print ('Error en la inserción de la Asada')
  22.         END
  23.     ELSE
  24.         commit tran
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement