Special paste from browser?

Hi,

Sometimes I need to make a lot of similar sentences, e.g.:

drop user a cascade;
drop user b cascade;
drop user c cascade;
...

I can select those users from browser, drag into SQL window and then select Name. But, I'll get

a,
b,
c,
...

And I've to change each line, which is painful.

Is there any other way to do it.

If not, here is a suggestion that might help in this and a lot of other cases.

Add a contextual menu called "Copy as pattern..." or something similar, or a context menu when you drag into window called "As pattern...". In any case, it would show up a dialog like this:

Please enter the pattern. Use %name% to replace object name:

[... type here ...]

[ OK ] [ CANCEL ]

So, you can type "drop user %name% cascade;" and you'll get the script in a moment.

It could be enhanced to include %table%, %constraintname% for example if you've selected some foreign keys, so you could generate "alter table %table% modify constraint %constraintname% disable;" which I find very useful.

Also, the textbox could be a combo and remember last sentences typed.

Can this be done already with some plugin? Could a plugin be developed to include this functionality using PL/SQL Developer APIs?

I know that "select 'alter table ' || table_name || ' modify constraint ' || constraint_name || ' disable;' from user_constraints where ..." can do basicly the same, but building this SQL is almost worse than typing it one-by-one... :o

Sorry if this is already done, I haven't been able to find it.
 
I assume by browser, you're talking about a query window?

If you're getting the user names from a database query, why not change the SELECT to work like this:

SELECT 'DROP USER ' || user_name || ';'
FROM ...

Works nicely.

Or am I missing something???
 
Such functionality is already done. You can simply use a Browser Extender plug-in [download from Allround Automations]
to easily create browser extensions (queries, pl/sql anonymous blocks) to do many repetitive tasks.

The Browser Extender installation already contains a few example extensions, among other a "Drop user cascade" extension.

Greetings,
Joachim Rupik
 
I haven't tried it, but would this plug-in do what you want??

Paste Options
With this Plug-In you can create multiple custom paste formats. You can add characters to the beginning or the end of the text that is pasted, replace characters and strip extra control characters.

Developed by Clouds
 
Back
Top