Just for hint:

U can use the deferrable option ---- define the RI is deferrable.

"constraint t_constraint foreign key(col.....,col...)
references table_name deferrable".

Then in program or trigger U can turn off/on this reference by:

"set constraint t_contraint deferred/immediate".

Take care