I have a function that returns me the status of a request (in the database it's int) that only has two possible values, 0 (inactive), 1 (active). I was trying to increment it with 'case when' in case the result is 0 it returns 'Inactive Request' or if the result is 1 it returns 'Active Request'. Below is my function:
create function NumPedidoStatus(@cod int)
returns int
as
begin
declare @Retorno int
set @Retorno=(select status from pedido where idPedido = @cod)
return @Retorno
end
What I tried to do was take the return value and use it in the 'case when', but I constantly encountered several errors and could not do it the way I described above.
I ended up not being able to do it and I would like someone to help me with what I should modify in this function so that it will work the way I want.
NOTE: I am using SQL SERVER