![]() |
Aunt
Augusta Archive:
|
![]() |
|
|
June 10 2002 Dear Aunt Augusta,
We are considering using stored PL/SQL procedures combined with external
C procedures or perhaps Java code to execute from a single place through
SQL*Net some operating system scripts to do some Oracle-related work,
such as renaming or compressing log files and the like. J.C.
Dear J.C., Ruling
the world from a single tiny place, what a noble ambition! I can only
approve of it. That said, it is not particularly easy to unmask the operating
system from PL/SQL - bar perhaps from a Java procedure, but I must confess
that Java is not quite my cup of tea. SQL> select file_name from dba_data_files will tell you without the shadow of a doubt that I am running on a Unix machine - You would probably have had no trouble either with say something like: cD:\ORACLE\ORIOLE1\SYSTEM01.DBF to guess the type of platform and anybody nearing my age would find: DISK$ORA:[ORIOLE1]SYSTEM01.DBF;1 totally
unambiguous. select substr(substr(banner, 1, instr(banner, ':') - 1), 9) OS
Sincerely yours,
~~~~~~~~~~~~
|
|
|
February 8 2002 G'day Auntie, An
old application has recently been totally rewritten and we're going to
put it into production soon. Quite obviously, the schema has been substantially
altered and we have to move all the data from the old format to the new
format. Our scripts have been successfully tested and are ready but they're
slow.
My dear antipodean friend, If I understand you right, you want updates to some tables to generate errors, except for the happy few. Methinks that triggers can prove quite handy at this. Have I already told you about the DBMS_APPLICATION_INFO package? Wonderful little package, which allows you neatly to make a difference between users, a bit like those welcoming signs 'UK passports' and 'Johnny Foreigners' (or something similar) which grace our borders and which you will no doubt notice the next time you enter the home country, whether you come on holiday or on parole. The idea is to create a little procedure which sets in your environment something which says that YOU CAN update; something like this : create or replace procedure allow_update
as
begin
dbms_application_info.set_module('UK PASSPORT', NULL);
end;
/
create public synonym allow_update for allow_update
/
Quite
obviously, you should not grant EXECUTE
on this to anybody and be unabashedly
elitist. create trigger substr(table_name, 1, 16)_READONLY_TRG before insert or delete or update onThis can be fairly easily generated for a huge number of tables by the means of a SQL script (you may want to have a look at the paper on how to write great DBA scripts in the 'First Steps' section of this site - useful for DBAs but not only them). Note that you must be careful, when generating the name of the trigger, not to make it longer than the 30-character limit, hence the substr() above. Beware if you have table names, the 16 first characters of which (in the example above) are identical. Those are simple techniques, which I am sure you will find most helpful during your data migration. Yours truly,
~~~~~~~~~~~~
|