Disable/Enable FK References

jlcox

Member³
Feature request: it would be handy to be able to disable and enable foreign key references for a table under the "Foreign key references" folder for a table. This is useful for truncating and importing rows for development databases.
 
Hello,

To do it, you can simply create an extension (command) with Browser Extender plug-in. You don't need to wait for a moment when an enhancement will be included. :)
Below is an extension file which disables foreign key references from referenced table point of view. Simply put it in a text file named, for example, Disable_FK.be.

Marco: I have discovered that when popup menu is opened for a foreign key object displayed within folder named "foreign key references" incorrect values are passed to plug-in API routine:

Type=FOLDER, Owner=, Name=TT_FK1 (TT), SubObject=

Greetings,
Joachim Rupik

--- snip ---
PL/SQL Developer Browser Extender Command

[MAIN]
NAME=TABLE - Disable foreign key references
CAPTION=Disable foreign key references
OTYPE=Table
OOWNER=%
ONAME=%
SEPARATOR_ABOVE=N
SEPARATOR_BELOW=N
LOAD_AND_EXECUTE=Y
LOAD_COMMAND=Y
LOAD_AFTER=EXECUTE
LOAD_WIN_TYPE=4
PRIVILEGE_REQ=N
PRIVILEGE=
ORACLE_VERSION_REQ=N
ORACLE_VERSION=7.0.0
ONCLICK_CONFIRM=N
ONCLICK_CONFIRM_MSG=
ONCLICK_SPLASH=N
ONCLICK_SPLASH_MSG=
ONCLICK_SPLASH_MSG_BL=N
ONCLICK_SPLASH_MSG_AFTER=
ONCLICK_SPLASH_DELAY=0
ONCLICK_IGNORE_EXCEPTIONS=N
ONPOPUP_IGNORE_EXCEPTIONS=Y

[ONCLICK]
select 'ALTER TABLE '||table_name||' disable CONSTRAINT '|| constraint_name ||';'
from all_constraints
where r_owner = '#oowner'
and constraint_type = 'R'
and r_constraint_name in (
select constraint_name
from all_constraints
where constraint_type in ('P', 'U')
and table_name = '#oname'
and owner = '#oowner'
and STATUS = 'ENABLED')

[ONPOPUP]
--- snip ---
 
Thanks, Joachim!

As long as we're on the subject of the Browser Extender, I don't see any way to specify that a BE command should reference the "Materialized views" folder. I would like to be able to run dbms_refresh.refresh on a materialized view from the context menu.
 
Simply edit the Be_Types.ini file and add 'Materialized View' line.

When standard Be_Types.ini file does not support the object type you want to create a command (extension) for,
just switch on 'trace enabled' and switch off 'Open this window as modal window' preferences, then open
the log panel and press 'Monitor log changes' button. Please remember, when 'Open this window as modal window'
preference was touched you must re-open Browser Extender Configuration window.
Now you have tracing enabled. Go to the object (in a PL/SQL browser panel) you want to add a menu item for
and right click. Popup menu will be shown and log panel will display similar line to the following one
- of course, when the object was materialized view :)

2005-04-08 08:39:00 : Opening Popup menu for item: Type=MATERIALIZED VIEW, Owner=SCOTT, Name=EMP_V, SubObject=

The 'MATERIALIZED VIEW' is what you need.

Joachim Rupik
 
Hello

I wonder if it is possible to make any use of any other attributes considering popup menu:

23.5.2005 19:34:08 : Opening Popup menu for item: Type=FOLDER, Owner=, Name=TABLES, SubObject=

As you can see from the this topic, I have made my custom folders named "datafiles", "redo logs", "tempfiles".

And now I would like to make distinct popups on:
Type=FOLDER & Name=REDO LOGS
Type=FOLDER & Name=DATAFILES
Type=FOLDER & Name=TEMPFILES
 
... silly me. that's my second post today without using brain enough.

Now I see I can make use of "Name" attribute in replacement scripts.

I apologize.
 
Back
Top