![]() |
Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! :pensando: hola espero que alguien me pueda ayudar con esto: Resulta que estoy haciendo un stored en donde declaro lo siguiente: @accion int, y las acciones que hace dentro del stored son estas 2: ---------------------------------------------------------------------------- if @accion=1 Begin delete from TempRServiciosProgramados where UsuarioActivo=@UsuarioActivo end ----------------------------------------------------------------------------- if @accion=2 begin Select A.Estatus from AsignacionServicio as AB,Actividad A where AB.IDUsuario=@IDUsuario and AB.IDSoporteServicio=@NSoporte and AB.IDSoporteServicio=A.IDSoporteServicio and AB.IDAsignacionServicio=A.IDAsignacionServicio and AB.IDServicio is null order by A.Estatus end -------------------------------------------------------------------------------- EL PROBLEMA ES QUE SI ME GUARDA EL STORED BIEN PERO A LA HORA DE MANDARLO LLAMAR ME MARCA ESTE ERROR: :abajo: Servidor: mensaje 201, nivel 16, estado 4, procedimiento sp_RServiciosProgramados, línea 0 El procedimiento 'sp_RServiciosProgramados' precisa el parámetro '@accion', que no se ha especificado. Porfavor si alguien sabe AYUDENMEEEEEEE!!!! |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! Simplemente no le has pasado ese parametro. Código: EXEC sp_RServiciosProgramados '@accion=1' |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! ESTE ES TODO EL STORED ESPERO LE ENTIENDAS Y ME PUEDAS AYUDAR :-) GRACIAS :si: alegna* CREATE proc sp_RServiciosProgramados_mod ( @UsuarioActivo varchar(10) = null, @NUsuario int = null, @CURP varchar(25) = null, @NSoporte int = null, @IDCategoria smallint = null, @IDEspecialidad smallint = null, @IDFederacion smallint = null, @IDServicio smallint = null, @IDSubServicio smallint = null, @FechaInicial datetime = null, @FechaFinal datetime = null, @IDInstalacion smallint = null, @accion int, @IDUsuario int =null ) as declare @strSQL varchar(5500) declare @FechaHoy datetime select @FechaHoy= getdate() if @accion=1 Begin delete from TempRServiciosProgramados where UsuarioActivo=@UsuarioActivo SET @strSQL = '' SET @strSQL = @strSQL + ' INSERT INTO TempRServiciosProgramados (Instalacion,Federacion,FechaInicio,FechaFin,Servi cio,' SET @strSQL = @strSQL + ' SubServicio,Nombre,ApellidoPaterno,ApellidoMaterno ,IDSoporteServicio,NumeroAtleta,' SET @strSQL = @strSQL +' CURP,IDCategoria,IDEspecialidad,IDFederacion,IDSer vicio,IDSubservicio,' SET @strSQL = @strSQL + ' UsuarioActivo, IDInstalacion, Habitacion,Sexo,IDUsuario)' SET @strSQL = @strSQL + 'SELECT I.Descripcion,F.Descripcion,convert(varchar(2),dat epart(mm,RAD.Fecha)) +' SET @strSQL = @strSQL + 'convert(varchar(2),datepart(dd,RAD.Fecha)) + convert(varchar(4),datepart(yyyy,RAD.Fecha)),' SET @strSQL = @strSQL + 'convert(varchar(2),datepart(hh,RAD.Hora))+ convert(varchar(2),datepart(mi,RAD.Hora)),' SET @strSQL = @strSQL + 'S.Descripcion,SS.Descripcion,U.Nombre,U.ApellidoP aterno, U.ApellidoMaterno,SP.IDSoporteServicio,' SET @strSQL = @strSQL + ' U.NumeroAtleta,U.CURP,U.IDCategoria,U.IDEspecialid ad,SP.IDFederacion, ASE.IDServicio,ASE.IDSubservicio,"'+@UsuarioActivo +'",U.IdEstatus, ASE.IDInstalacion,ASE.NumeroHabitacion,U.Sexo,U.ID Usuario' SET @strSQL = @strSQL + 'from' SET @strSQL = @strSQL + ' AsignacionServicio as ASE,Federacion as F,Servicio as S,Subservicio as SS,Instalacion as I, SoporteServicio as SP,Usuario as U,' SET @strSQL = @strSQL + 'Where' SET @strSQL = @strSQL + ' ASE.IDServicio = S.IDServicio ' SET @strSQL = @strSQL + ' and ASE.IdServicio = SS.IDServicio ' SET @strSQL = @strSQL + ' and ASE.IdSubServicio = SS.IDSubservicio' SET @strSQL = @strSQL + 'and RAD.IdSubServicio = SS.IDSubservicio' SET @strSQL = @strSQL + 'and ASE.FechaFin>=convert(varchar(2),datepart(mm,@Fech aHoy)),' SET @strSQL = @strSQL + '+convert(varchar(2),datepart(dd,@FechaHoy))+ convert(varchar(4),datepart(yyyy,@FechaHoy))' if len(@IDSubServicio)>0 BEGIN SET @strSQL = @strSQL + 'and R.IdSubServicio = ' + cast(@IDSubServicio as varchar(6)) END SET @strSQL = @strSQL + 'and S.IdServicio = SubS.IdServicio' if len(@IDServicio)>0 BEGIN SET @strSQL = @strSQL + 'and S.IdServicio = ' + cast(@IDServicio as varchar(3)) END SET @strSQL = @strSQL + 'and R.IdInstalacion = I.IdInstalacion' if len(@IDInstalacion)>0 BEGIN SET @strSQL = @strSQL + 'and R.IdInstalacion = ' + cast(@IDInstalacion as varchar(3)) END SET @strSQL = @strSQL + 'and C.IdCategoria = U.IdCategoria' if len(@IDCategoria)>0 BEGIN SET @strSQL = @strSQL + 'and C.IdCategoria = ' + cast(@IDCategoria as varchar(2)) END SET @strSQL = @strSQL + 'and F.IdFederacion= U.IdFederacion' if len(@IDFederacion)>0 BEGIN SET @strSQL = @strSQL + 'and F.IdFederacion= ' + cast(@IDFederacion as varchar(2)) END SET @strSQL = @strSQL + 'and U.IdEspecialidad= Esp.IdEspecialidad' if len(@IDEspecialidad)>0 BEGIN SET @strSQL = @strSQL + 'and U.IdEspecialidad= ' + cast(@IDEspecialidad as varchar(2)) END SET @strSQL = @strSQL + 'and U.IdEstatus= E.IdEstatus' if len(@NUsuario)>0 BEGIN SET @strSQL = @strSQL + 'and U.NumeroAtleta = ' + cast(@NUsuario as varchar(6)) END if len(@NSoporte) > 0 BEGIN SET @strSQL = @strSQL + 'and R.IdSoporteServicio = ' + cast(@NSoporte as varchar(6)) END exec (@strSQL) if len(@Curp)>0 BEGIN delete from TempResumenOtorgados where CURP <> @CURP and UsuarioActivo=@UsuarioActivo END If len(@FechaInicial)>0 BEGIN Select Instalacion,Federacion, convert(varchar(2),datepart(mm,FechaInicio)) + '/'+ convert(varchar(2),datepart(dd,FechaInicio)) + '/'+ convert(varchar(4),datepart(yyyy,FechaInicio)), convert(varchar(2),datepart(mm,FechaFin)) + '/'+ convert(varchar(2),datepart(dd,FechaFin)) + '/'+ convert(varchar(4),datepart(yyyy,FechaFin)), Servicio, Subservicio,Nombre,ApellidoPaterno,ApellidoMaterno ,IDSoporteServicio,NumeroAtleta, CURP,IDCategoria,IDEspecialidad,IDFederacion,IDSer vicio,IDSubservicio,UsuarioActivo,IDInstalacion, Habitacion,Sexo,IDUsuario from TempRServiciosProgramados where UsuarioActivo=@UsuarioActivo order by IDInstalacion,IDFederacion,IDServicio,IDSubservici o,FechaInicio,NumeroAtleta,IDSoporteServicio END else BEGIN Select Instalacion,Federacion, convert(varchar(2),datepart(mm,FechaInicio)) + '/'+ convert(varchar(2),datepart(dd,FechaInicio)) + '/'+ convert(varchar(4),datepart(yyyy,FechaInicio)), convert(varchar(2),datepart(mm,FechaFin)) + '/'+ convert(varchar(2),datepart(dd,FechaFin)) + '/'+ convert(varchar(4),datepart(yyyy,FechaFin)), Servicio, Subservicio,Nombre,ApellidoPaterno,ApellidoMaterno ,IDSoporteServicio,NumeroAtleta, CURP,IDCategoria,IDEspecialidad,IDFederacion,IDSer vicio,IDSubservicio,UsuarioActivo,IDInstalacion, Habitacion,Sexo,IDUsuario from TempRServiciosProgramados where UsuarioActivo=@UsuarioActivo order by IDInstalacion,IDFederacion,IDServicio,IDSubservici o,FechaInicio,NumeroAtleta,IDSoporteServicio END END if @accion=2 begin Select A.Estatus from AsignacionServicio as AB,Actividad A where AB.IDUsuario=@IDUsuario and AB.IDSoporteServicio=@NSoporte and AB.IDSoporteServicio=A.IDSoporteServicio and AB.IDAsignacionServicio=A.IDAsignacionServicio and AB.IDServicio is null order by A.Estatus end return 0 GO |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! Si cambias @accion int por @accion int null ya no tendras ese problema. Ahora la pregunta seria se puede dar ese caso? Asi como tienes tu SP @accion es parametro obligatorio. |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! Ya intente eso del NULL y si como dices ya no tiene problemas pero el resultado al mandar llamar al prodecure deberia ser todo lo que se especifica en el select y no lo hace unicamente pone en el resultado " Comandos completados con éxito." Eso es lo malo :'( Si tienes alguna otra sugerencia te lo agradecería :-) alegna :adios: |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! Amigo alegna_13, tienes aumentar codigo a tu SP para el caso que la accion tenga un valor null. Y te repito, no le estas pasando el valor de accion. Segun vi, accion toma dos valores: 1 y 2. A ver muestra como llamas al SP. |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! HOLA DE NUEVO !!! :-) Pues resulta que despues de mucho pensarle y moverle para tratar de sacar algun resultado ví que declarando ambas variables que ocupo de @accion el resultado fue bueno; me trajo toda la informacion del select. No tengo idea si esto ya este bien asi tendría que revisarlo con mi jefa pero por el momento sería una solucion tentativa. -------------------------- @accion int=1, @accion_s int=2, --------------------------- Si tienen alguna otra solucion se las agradecería :si: alegna:adios: |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! :neurotico PARA LLAMAR AL STORE UNICAMENTE LO LLAMO CON EL NOMBRE : ------------------------------------------------- sp_RServiciosProgramados_mod :pensando: --------------------------------------------------- Asi es como logre que me mostrara las columnas. Eso esta mal??? :ojotes: alegna:adios: P.D. Te agradezco tu tiempo para revisar el stored :-) |
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!! Creo que ya entendi lo que querias. Tu querias que al no pasarle la accion se ejecute ambos bloques (cuando accion es 1 y 2), cierto? Si es asi pon: Código: ... |
| La zona horaria es GMT -6. Ahora son las 22:45. |
Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.