Retroceder   Foros del Web > Programación para sitios web > Bases de Datos > SQL Server

Respuesta
 
Herramientas Desplegado
Antiguo 24-abr-2008, 13:56   #1 (permalink)
alegna_13 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Ubicación: MEXICO D.F.
Mensajes: 11
Exclamación Problemas Con Parametros En El Stored Procedure!!!!!!!!!!!

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:

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!!!!
alegna_13 está desconectado   Responder Citando
Antiguo 24-abr-2008, 14:09   #2 (permalink)
flaviovich está en el buen camino
 
Avatar de flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 1.128
Enviar un mensaje por ICQ a flaviovich Enviar un mensaje por MSN a flaviovich Enviar un mensaje por Skype™ a flaviovich
Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!!

Simplemente no le has pasado ese parametro.
Código:
EXEC sp_RServiciosProgramados '@accion=1'
Seria mejor que muestres tu SP.
__________________
Если можешь читать это, то напиши мне..
No repitamos temas, usemos el Motor de busquedas
flaviovich está desconectado   Responder Citando
Antiguo 24-abr-2008, 14:16   #3 (permalink)
alegna_13 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Ubicación: MEXICO D.F.
Mensajes: 11
Exclamación Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!!

ESTE ES TODO EL STORED ESPERO LE ENTIENDAS Y ME PUEDAS AYUDAR
GRACIAS 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
alegna_13 está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:09   #4 (permalink)
flaviovich está en el buen camino
 
Avatar de flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 1.128
Enviar un mensaje por ICQ a flaviovich Enviar un mensaje por MSN a flaviovich Enviar un mensaje por Skype™ a flaviovich
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.
__________________
Если можешь читать это, то напиши мне..
No repitamos temas, usemos el Motor de busquedas
flaviovich está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:15   #5 (permalink)
alegna_13 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Ubicación: MEXICO D.F.
Mensajes: 11
Exclamación 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
alegna_13 está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:39   #6 (permalink)
flaviovich está en el buen camino
 
Avatar de flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 1.128
Enviar un mensaje por ICQ a flaviovich Enviar un mensaje por MSN a flaviovich Enviar un mensaje por Skype™ a flaviovich
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.
__________________
Если можешь читать это, то напиши мне..
No repitamos temas, usemos el Motor de busquedas
flaviovich está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:42   #7 (permalink)
alegna_13 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Ubicación: MEXICO D.F.
Mensajes: 11
Exclamación 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


alegna
alegna_13 está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:48   #8 (permalink)
alegna_13 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Ubicación: MEXICO D.F.
Mensajes: 11
Exclamación Re: Problemas Con Parametros En El Stored Procedure!!!!!!!!!!!

PARA LLAMAR AL STORE UNICAMENTE LO LLAMO CON EL NOMBRE :

-------------------------------------------------
sp_RServiciosProgramados_mod

---------------------------------------------------

Asi es como logre que me mostrara las columnas. Eso esta mal???


alegna

P.D. Te agradezco tu tiempo para revisar el stored
alegna_13 está desconectado   Responder Citando
Antiguo 24-abr-2008, 15:54   #9 (permalink)
flaviovich está en el buen camino
 
Avatar de flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 1.128
Enviar un mensaje por ICQ a flaviovich Enviar un mensaje por MSN a flaviovich Enviar un mensaje por Skype™ a flaviovich
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:
...
if @accion=1 OR @accion IS NULL
...
if @accion=2 OR @accion IS NULL
Suerte!
__________________
Если можешь читать это, то напиши мне..
No repitamos temas, usemos el Motor de busquedas
flaviovich está desconectado   Responder Citando
Respuesta
Calificación: Calificación de Tema: 1 votos, 3,00 de promedio.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 01:56.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93