TO_NUMBER - functionality in Trigger
524171Jul 20 2006 — edited Jul 20 2006hi,
i have problems creating a Trigger that uses the TO_NUMBER-function.
There's a Field VK_PREIS (nvarchar2) filled with prices from products.
because not all values in this field are numeric (e.g. "N.A." ) , i want to copy the numeric value to VK_PREIS_NUM (Number) by a trigger :
CREATE OR REPLACE TRIGGER "TR_KALENDER_PREIS"
BEFORE INSERT OR UPDATE ON "KALENDER"
FOR EACH ROW
BEGIN
:NEW.VK_PREIS_NUM := TO_NUMBER(DECODE(LENGTH(TRIM(TRANSLATE(trim(:NEW.VK_PREIS), ' +-.,0123456789',' '))), NULL, REPLACE(:NEW.VK_PREIS, '.', ','), '0'));
END;
but every time i update a dataset, the trigger throws an exception "("VDI"."TR_KALENDER_PREIS" is invalid and failed re-validation"
if i just copy the value ( :NEW.VK_PREIS_NUM := :NEW.VK_PREIS; ) i get no error.
any ideas?
(sorry for my bad english)