oracle - PL/SQL Before Trigger - Inherit column from other table -


i'm very new pl/sql excuse ignorance on subject, i'd appreciate help!

i have these 2 tables, let's say, ratings , games.

suppose want inherit value ratings table , insert game table automatically depending on gamerating (inheriting ratings table) gave it.

on game table have: (gameid, gameprice, gamename, gamerating, gameages, publisherid)

and on ratings table have: (ratingid, ratingcode, ratingages)

if insert following values game: (1,50,'lost','m') want automatically insert gameages ratings table using gamerating basis reading ratings table, ratingcode.

how go on doing this?

all know have declare variables , insert ages them depending on gamerating.

edit:

managed guys,

here's format used:

create or replace trigger [triggername]

before insert on [tablename]

for each row

declare

[variables]

begin

select [columns populate variables] [variables] [second table] join [first table] on [secondtableid] = :new.[firsttableid] group [columns pop variables] order max([firsttableid])

:new.[firsttablecolumn] := [variables]

end

hope helps in future

create or replace trigger [triggername] before insert on [tablename] each row declare [variables] begin select [columns populate variables] [variables] [second table] join [first table] on [secondtableid] = :new.[firsttableid] group [columns pop variables] order max([firsttableid]) :new.[firsttablecolumn] := [variables] end 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -