Receive parameter and depending on the value run a specific process

Asked

Viewed 70 times

0

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

I tried to do so:

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 on line 31 end'

It is possible to do this?

  • use without the then, in the end you send exec(ssql1) that it will run the query that you generated!

  • I took the then and the error appeared: 'Then' expected

  • Here has a good example!

1 answer

0


Create a single file and run this selection within the same Sql server.

declare @typoagenda int

set @gendoagenda = 1

if @typoagenda = 1 Begin print 'exec Verified Available' end Else if @typoagenda = 2 Begin print 'exec Verifiedavailable_request' end Else print 'exec Checkavailability & rescheduling'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.