Subject | Re: [firebird-support] help Store Procedure |
---|---|
Author | Helen Borrie |
Post date | 2003-11-29T23:39:58Z |
At 09:30 PM 29/11/2003 +0000, you wrote:
result of the multiplication back to the correct scale for PRECIO (let's
assume PRECIO is DECIMAL(18,2).
Next, the calculation will update the price to a *fraction* of its starting
value. Surely you don't want that?
Shouldn't this be:
UPDATE SUC_ART
SET PRECIO=PRECIO + CAST((PRECIO * :INCREMENTO) AS DECIMAL(18,2);
>Wrong ?I see two problems with this line:
>
>CREATE PROCEDURE SP_INC (
> SUCUR INTEGER,
> INCREMENTO DECIMAL (2, 2))
>AS
>BEGIN
>if (incremento <> 0) then
>
> BEGIN
> UPDATE SUC_ART SET PRECIO=PRECIO*:INCREMENTOFirst, INCREMENTO has two places of decimal, so you will need to CAST the
result of the multiplication back to the correct scale for PRECIO (let's
assume PRECIO is DECIMAL(18,2).
Next, the calculation will update the price to a *fraction* of its starting
value. Surely you don't want that?
Shouldn't this be:
UPDATE SUC_ART
SET PRECIO=PRECIO + CAST((PRECIO * :INCREMENTO) AS DECIMAL(18,2);
> WHERE ID_SUC= :SUCUR ;\heLen
> SUSPEND; <------------------remove this - suspend is used for making
> output sets.
> END
>END
>I must run a store procedure than update al the recordos from a
>SUCURSAL and increment the PRICE (PRECIO) with a PORCENT
>I don't know whats wrong with this?