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(cobol date 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(cobolho lddate)), 'yymmdd');
Else
If length(coboldate) = 4 then
cobolholddate := '00' || coboldate ;
Result := to_date((to_number(cobolho lddate)), 'yymmdd');
Else
If length(coboldate) = 5 then
cobolholddate := '0' || coboldate ;
Result := to_date((to_number(cobolho lddate)), 'yymmdd');
Else
Result := to_date((to_number(cobolho lddate)), 'yymmdd');
End if;
End if;
End if;
End if;
End if;
RETURN Result;
End;
End;
/
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
,sysdate
);
end;
/
DROP FUNCTION fn_FmtCblDate_YYMMDD;
Create Function fn_FmtCblDate_YYMMDD(cobol
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(cobolho
Else
If length(coboldate) = 4 then
cobolholddate := '00' || coboldate ;
Result := to_date((to_number(cobolho
Else
If length(coboldate) = 5 then
cobolholddate := '0' || coboldate ;
Result := to_date((to_number(cobolho
Else
Result := to_date((to_number(cobolho
End if;
End if;
End if;
End if;
End if;
RETURN Result;
End;
End;
/
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
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)
....
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)
....
ASKER
With and without the typos I'm getting the same error when try to update
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.