Receive parameter and depending on the value execute a specific procedure

0

I have a system in Classic Asp, and I need to execute a specific SQL Server procedure, according to a parameter that the system receives from a form.

I tried to do this:

if tipoagenda = 1 then
   ssql1 = "exec VerificaDataDisponivel"
elseif tipoagenda = 2 then
   ssql1 = "exec VerificaDataDisponivel_Pedido"
else 
   ssql1 = "exec VerificaDataDisponivel_Reagenda"
end if

or so:

.CommandType = adCmdStoredProc
if tipoagenda = 1 then 
   .CommandText = "HorarioDisponivelHomolog"
elseif tipoagenda = 2 then
   .CommandText = "HorarioDisponivelHomolog_Pedido"
else 
   .CommandText = "HorarioDisponivelHomolog_Reagenda"
end

But it gives error saying 'if' expected at line 31 end '

Is it possible to do this?

    
asked by anonymous 21.02.2017 / 18:29

1 answer

0

Create a single procedure and execute this selection within the same SQl server.

declare @type int

set @type = 1

if @typeagenda = 1 begin    print 'exec VerifyDataAvailable'  end else if @type = 2 begin     print 'exec VerifyDataAvailable_Data' end else     print 'exec VerifyAvailableDatabase'

    
21.03.2017 / 18:20