i'm making trigger checks if person can go world or european championship, , if go car, calculates how spent on fuel(fuelcost * spends * distance/100). need put info in table i'm getting message:
error(24,66): pl/sql: ora-00984: column not allowed here
that's because i've put "fuelcost * spends * :new.distance/100" in insert statement @ bottom of code. question is, how can put value in table costs in different way. column costs.money not calculated column because it's not fuel costs in table, isn't solution.
create or replace trigger check_norm_fuel_cost instead of insert or update on insert_travel_view each row declare hasnorm char(1); spends number; fuelcost number; begin select norms.norm hasnorm norms join competitions on competitions.competitionid=norms.competitionid :new.personid = norms.personid , (competitions.name 'european championship' or competitions.name 'world championship'); if hasnorm = 'y' or hasnorm null insert travel(travelid, personid, competitionid, vehicleid, distance) values (:new.travelid, :new.personid, :new.competitionid, :new.vehicleid, :new.distance); if :new.distance not null select vehicles.consumption spends vehicles :new.vehicleid = vehicles.vehicleid; select fuels.cost fuelcost fuels join vehicles on vehicles.fuelid = fuels.fuelid :new.vehicleid = vehicles.vehicleid; insert costs(costid, costtype, travelid, money) values(35, 'fuel', :new.travelid, fuelcost*spends*:new.distance/100); end if; end if; end;
try change explicit values in insert statement select insert into(...) select .... , sorry bad formatting writing mobile.
Comments
Post a Comment