Skip to content
Advertisement

Trigger SQL statement

Hi so I have am writing a statement to create a trigger in Oracle that would append the text to the description of every new game inserted into the database.

I want the format to be like

enter image description here

enter image description here

GenreID and subGenre in Game Table is foreign key to Genre Table.

GameID Sequence

GameID Trigger

Game Description Trigger

I’m not sure where I’m doing wrong. But I keep getting “Warning: Trigger created with compilation errors.”

Advertisement

Answer

What did you do wrong? Several things.

TR_GAMEID is OK (although, could be rewritten as)


GAME_DES isn’t OK, suffers from various errors.

  • it isn’t before insert OF but ON
  • the 2nd select refrences subgenreid column from the genre table, but – according to what you posted – such a column doesn’t exist in the table (but exists in game)
  • concat allows only 2 parameters. You’d rather switch to double pipe || concatenation operator.
    • also, you’re concatenating some rating and title things which are unknown. What are they?

The following trigger compiles but is probably wrong as the 2nd select looks suspicious.


Also, a piece of advice: when Oracle says you got errors, ask it which ones they were. How? Like this (in SQL*Plus) (this is your code):

Alternatively, query USER_ERRORS:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement