witzman
Grünschnabel
Die Berechnung und die Selects funktioniern, ich bekome immer richtige Ergebnisse, aber das mit dem errorcode/rowcount nicht
Der erste if Teil funktioniert, der 2 funktioniert auch.
Aber ich will, dass er, wenn er Werte findet, den errorcode auf 0 setzt...
bzw auf 1 stehenlaesst, wenn was nichts gefunden wird.
Waere nett, wenn mir einer helfen kann.
cu
Witzman
ALTER PROCEDURE usp_GET_changeCurrency (
@wert float,
@origCurr int,
@newcurr int,
@exchangeratetype smallint
)
AS
Declare @ValidFrom datetime,
@ratio as float,
@newwert as float,
@changedtime as datetime,
@error_code as int,
@ratio2 as float
SET @error_code = 1
SET @ratio2 = 1
SET @changedtime = getdate()
/*
Wenn x > x
*/
if @origcurr = @newcurr
begin
SET @error_code = 0
SET @ratio = 1
SET @newwert = @wert
Select @newwert as newwert, @ratio as rate, @changedtime as changedtime, @error_code as errorcode
end
/*
Wenn Euro > x
*/
if @origcurr = 1
begin
SELECT @validfrom = Max(CUR_ExchangerateValidFrom) FROM tbl_CUR_Exchangerate WHERE (CUR_ExchangerateType = @ExchangeRateType) AND (CUR_ForeignCurrencyID = @newCurr)
IF @@ROWCOUNT = 0
begin
Select @error_code as errorcode
end
Else
begin
SET @error_code = 0
SELECT @ratio = CUR_ExchangeRatioReverse
FROM tbl_CUR_Exchangerate
WHERE CUR_ExchangerateType = @ExchangeRateType AND CUR_ForeignCurrencyID = @newcurr AND CUR_ExchangerateValidFrom = @ValidFrom
SET @newwert = @wert * @ratio
Select @newwert as newwert, @ratio as rate, @changedtime as changedtime, @error_code as errorcode
end
end
RETURN
Der erste if Teil funktioniert, der 2 funktioniert auch.
Aber ich will, dass er, wenn er Werte findet, den errorcode auf 0 setzt...
bzw auf 1 stehenlaesst, wenn was nichts gefunden wird.
Waere nett, wenn mir einer helfen kann.
cu
Witzman
ALTER PROCEDURE usp_GET_changeCurrency (
@wert float,
@origCurr int,
@newcurr int,
@exchangeratetype smallint
)
AS
Declare @ValidFrom datetime,
@ratio as float,
@newwert as float,
@changedtime as datetime,
@error_code as int,
@ratio2 as float
SET @error_code = 1
SET @ratio2 = 1
SET @changedtime = getdate()
/*
Wenn x > x
*/
if @origcurr = @newcurr
begin
SET @error_code = 0
SET @ratio = 1
SET @newwert = @wert
Select @newwert as newwert, @ratio as rate, @changedtime as changedtime, @error_code as errorcode
end
/*
Wenn Euro > x
*/
if @origcurr = 1
begin
SELECT @validfrom = Max(CUR_ExchangerateValidFrom) FROM tbl_CUR_Exchangerate WHERE (CUR_ExchangerateType = @ExchangeRateType) AND (CUR_ForeignCurrencyID = @newCurr)
IF @@ROWCOUNT = 0
begin
Select @error_code as errorcode
end
Else
begin
SET @error_code = 0
SELECT @ratio = CUR_ExchangeRatioReverse
FROM tbl_CUR_Exchangerate
WHERE CUR_ExchangerateType = @ExchangeRateType AND CUR_ForeignCurrencyID = @newcurr AND CUR_ExchangerateValidFrom = @ValidFrom
SET @newwert = @wert * @ratio
Select @newwert as newwert, @ratio as rate, @changedtime as changedtime, @error_code as errorcode
end
end
RETURN