Link to home
Start Free TrialLog in
Avatar of bolicat
bolicat

asked on

ORA-01733: virtual column not allowed here

Bellow are my Tble, view, trigger and fuction when try to update the table using the view getting

ERROR at line 3:
ORA-01733: virtual column not allowed here



create table SKU_FUTURE_COST (
      IMAGE_RECNBR number(10) not null
     ,SKU varchar2(20) not null                    
    DATE_COST_EFF date -- yymmdd                
  );

create view VS_SKU_FUTURE_COST
   as select
   IMAGE_RECNBR
   ,SKU
   ,DATE_COST date -- yymmdd
   from SKU_FUTURE_COST
/

create or replace trigger SKU_FUTURE_COST_VIR
instead of insert on VS_SKU_FUTURE_COST
begin
   insert into SKU_FUTURE_COST (
         SKU
        ,DATE_COST_EFF
        ,Date_Add_Trigger
      ) values (
         :new.SKU
        ,fn_FmtCblDate_YYMMDD(:new.DATE_COST_EFF)
        ,sysdate
      );
end;
/

DROP FUNCTION fn_FmtCblDate_YYMMDD;

Create Function fn_FmtCblDate_YYMMDD(coboldate char)
   RETURN DATE AS
Begin
 Declare
  cobolholddate char(6);
  Result date;
 Begin
  IF coboldate = ' ' then
    Result := NULL;
  Else
    If coboldate = '000000' then
     Result := NULL;
    Else
    If length(coboldate) = 3 then
         cobolholddate  := '000' || coboldate ;
         Result :=  to_date((to_number(cobolholddate)), 'yymmdd');
    Else    
    If length(coboldate) = 4 then
         cobolholddate  := '00' || coboldate ;
         Result :=  to_date((to_number(cobolholddate)), 'yymmdd');
    Else      
    If length(coboldate) = 5 then
         cobolholddate  := '0' || coboldate ;
         Result :=  to_date((to_number(cobolholddate)), 'yymmdd');
    Else    
         Result :=  to_date((to_number(cobolholddate)), 'yymmdd');
    End if;
    End if;
    End if;
    End if;
 End if;
  RETURN Result;
 End;
End;
/
Avatar of paquicuba
paquicuba
Flag of United States of America image

,DATE_COST date -- yymmdd
date -- is a reserved word

Put double quotes around it:

SQL> select sysdate date from dual;
select sysdate date from dual
               *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


Elapsed: 00:00:00.00
SQL> select sysdate "date" from dual;

date
---------
16-NOV-04

1 row selected.
Avatar of bolicat
bolicat

ASKER

I'm not trying to select, I'm trying to update, delete and insert.
The insert work.

P.S. I'm no usnig the date in the view this is a typo

Thanks
You have other typos:

In view VS_SKU_FUTURE_COST ",DATE_COST" is not a SKU_FUTURE_COST
column.

In trigger SKU_FUTURE_COST_VIR except for DATE_COST_EFF,
the INSERT does not refer to any of SKU_FUTURE_COST:
   insert into SKU_FUTURE_COST (
         SKU
        ,DATE_COST_EFF
        ,Date_Add_Trigger)
....
Avatar of bolicat

ASKER

With and without the typos I'm getting the same error when try to update
ASKER CERTIFIED SOLUTION
Avatar of alexfrl
alexfrl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial