Guest User

Untitled

a guest
Apr 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. Create Procedure [dbo].[sp_i_programa_semanal] (@BarNom varchar(50),
  2. @Fecha datetime,
  3. @h1 numeric (10, 4),
  4. @h2 numeric (10, 4),
  5. @h3 numeric (10, 4),
  6. @h4 numeric (10, 4),
  7. @h5 numeric (10, 4),
  8. @h6 numeric (10, 4),
  9. @h7 numeric (10, 4),
  10. @h8 numeric (10, 4),
  11. @h9 numeric (10, 4),
  12. @h10 numeric (10, 4),
  13. @h11 numeric (10, 4),
  14. @h12 numeric (10, 4),
  15. @h13 numeric (10, 4),
  16. @h14 numeric (10, 4),
  17. @h15 numeric (10, 4),
  18. @h16 numeric (10, 4),
  19. @h17 numeric (10, 4),
  20. @h18 numeric (10, 4),
  21. @h19 numeric (10, 4),
  22. @h20 numeric (10, 4),
  23. @h21 numeric (10, 4),
  24. @h22 numeric (10, 4),
  25. @h23 numeric (10, 4),
  26. @h24 numeric (10, 4))
  27. As
  28. Begin
  29. Set nocount on
  30.  
  31. Declare @codigo_barra int
  32. Declare @count_reg int
  33. --select * from tb_programa_semanal
  34. --sp_help tb_programa_semanal
  35.  
  36.  
  37. select @codigo_barra = codigo_barra
  38. from tb_barra
  39. where descripcion_barra = @BarNom
  40.  
  41. select @count_reg = count(*)
  42. from tb_programa_semanal
  43. where codigo_barra = @codigo_barra
  44. and Fecha = @Fecha
  45. if (@count_reg = 0)
  46. Begin
  47. insert into tb_programa_semanal (Codigo_barra,Fecha,FP_h1,FP_h2,FP_h3,FP_h4,FP_h5,FP_h6,
  48. FP_h7,FP_h8,FP_h9,FP_h10,FP_h11,FP_h12,FP_h13,FP_h14,FP_h15,
  49. FP_h16,FP_h17,FP_h18,FP_h19,FP_h20,FP_h21,FP_h22,FP_h23,FP_h24)
  50. values (@codigo_barra,@Fecha,@h1,@h2,@h3,@h4,@h5,@h6,@h7,@h8,@h9,@h10,@h11,@h12,@h13,@h14,
  51. @h15,@h16,@h17,@h18,@h19,@h20,@h21,@h22,@h23,@h24)
  52. End --fin if (@count_reg = 0)
  53. Else
  54. Begin
  55. update tb_programa_semanal
  56. set FP_h1 = @h1,
  57. FP_h2 = @h2,
  58. FP_h3 = @h3,
  59. FP_h4 = @h4,
  60. FP_h5 = @h5,
  61. FP_h6 = @h6,
  62. FP_h7 = @h7,
  63. FP_h8 = @h8,
  64. FP_h9 = @h9,
  65. FP_h10 = @h10,
  66. FP_h11 = @h11,
  67. FP_h12 = @h12,
  68. FP_h13 = @h13,
  69. FP_h14 = @h14,
  70. FP_h15 = @h15,
  71. FP_h16 = @h16,
  72. FP_h17 = @h17,
  73. FP_h18 = @h18,
  74. FP_h19 = @h19,
  75. FP_h20 = @h20,
  76. FP_h21 = @h21,
  77. FP_h22 = @h22,
  78. FP_h23 = @h23,
  79. FP_h24 = @h24
  80. where codigo_barra = @codigo_barra
  81. and Fecha = @Fecha
  82. End --fin else
Add Comment
Please, Sign In to add comment