$1 FUNCTION [dbo].[fn_StokSatisFiyat] (@barkod nvarchar(25)='',
@depo int,--0 tüm depolar
@fiyatNo int)
RETURNS float
AS
BEGIN
DECLARE @VAL As Float
SELECT @VAL=
CASE 
WHEN @fiyatNo=1 THEN bar_birim_fiyat1 
WHEN @fiyatNo=2 THEN bar_birim_fiyat2
WHEN @fiyatNo=3 THEN bar_birim_fiyat3 
WHEN @fiyatNo=4 THEN bar_birim_fiyat4
WHEN @fiyatNo=5 THEN bar_birim_fiyat5  END
FROM STOK_BARKOD_TANIMLARI
WHERE bar_barkodu=@barkod AND bar_depono=@depo 
IF @VAL is NULL SET @VAL=0
RETURN ROUND(@VAL,2)
END