Quantcast
Channel: Programação de Function
Viewing all articles
Browse latest Browse all 3

Programação de Function

$
0
0
--testes: SELECT coluna2 = dbo.rendaCliente1(3);

create function dbo.rendaCliente1 (@Codigo int)

returns float
as
begin
        declare @renda float
   	    set @renda = (select top 1 renda from cliente (NOLOCK) where cod = @Codigo); 

		if (select TOP 1 estadoCivil from cliente (NOLOCK) where cod = @Codigo) = 'casado'
        BEGIN
			IF exists(select TOP 1 isnull(renda_conjuge,0) from conjuge (NOLOCK) where codCliente = @Codigo)
				set @renda = @renda + (select TOP 1 isnull(renda_conjuge,0) from conjuge  (NOLOCK) where codCliente = @Codigo);
		end
        return @renda
end



Viewing all articles
Browse latest Browse all 3


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>