0

I have two tables:

  • BIRACI(ID, broj_biraca)
  • PRAVNI_AKT_PREDLOG_BIRACA(Pravni_akt_id, ID_biraca(FK from BIRACI)

When I want to insert into table PRAVNI_AKT_PREDLOG_BIRACA I need some rule to check if inserted ID_biraca has its attribute in table BIRACI with the condition broj_biraca > 15000.

I need something to show error like "Insertion not possible, BIRACI with that ID isnt having 15000 or more in broj_biraca"... Is this possible?

1 Answers1

0

I'm not an Oracle expert but I've searched a bit and it seems that Oracle doesn't support check constraints that reference another table.

2 potential workarounds:

  1. According to https://stackoverflow.com/a/3880853/6996150 it could work via a user defined function (however this seems not the case according to Oracle's documentation; cf. the following approach).

  2. According to https://stackoverflow.com/a/41467321/6996150 it could be done via virtual columns.

Hopefully you can make it work!

johey
  • 1,139
  • 1
  • 9
  • 25