Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2013, 07:48
gus_anomaly
 
Fecha de Ingreso: noviembre-2009
Mensajes: 381
Antigüedad: 14 años, 5 meses
Puntos: 6
Store Proc y una consulta

Buenas amigos, estoy iniciando en este mundo de los Stores Procedures, para ello estoy haciendo unos ejercicios pero aqui un problema con el siguiente:

Lo estoy creando con SQL 2008 R2 y los ejecuto desde VB, igualmente los ejecuto desde el SQL mismo y me da el mismo error, aqui el SP:

Código SQL:
Ver original
  1. SET ANSI_NULLS ON
  2. GO
  3. SET QUOTED_IDENTIFIER ON
  4. GO
  5.  
  6. ALTER PROCEDURE [dbo].[CALCULO_PRECIO]
  7.    
  8.     @FECHA DATE,
  9.     @MONTO INT,
  10.     @DIF_DIA INT,
  11.     @PORC INT,
  12.     @PUN INT OUTPUT,
  13.     @MONTO_TOT INT OUTPUT  
  14.  
  15. AS
  16. BEGIN
  17.    
  18.     SET @DIF_DIA = DATEDIFF(DAY, CONVERT(DATE,getdate(),103), @FECHA)  
  19.  
  20.                 IF @DIF_DIA > 30
  21.                     SET @PORC = 20
  22.                 ELSE
  23.                 IF @DIF_DIA > 15  
  24.                     SET @PORC = 12
  25.                 ELSE
  26.                 IF @DIF_DIA > 7
  27.                     SET @PORC = 8    
  28.                 ELSE
  29.                 SET @PORC = 0
  30.                
  31.                 SET @PUN = @MONTO * @PORC / 100
  32.                 SET @MONTO_TOT = @MONTO + @PUN
  33.    
  34. END
  35. GO

Lo llamo pasando los 2 parametros que recibiria desde VB:

Código SQL:
Ver original
  1. EXEC dbo.CALCULO_PRECIO '04-07-2013', 200

El error:

Procedure or function 'CALCULO_PRECIO' expects parameter '@PUN', which was not supplied.


Entiendo que esta esperando un valor en esa variable, pero esa variable esta seteada pasa su uso unicamente dentro del store.

Ok, cualquier ayuda estaré muy agradecido-
Gustav.