Question

One of our smaller clients have their own database in which they maintain a small IT team. Sometimes, this small team of IT has to make their own modifications to their database, but sometimes, they do not verify the scripts that our company provides for them - and reuse them at their own will. This sometimes leads to duplicate jobs, where a member of this team executes the same scripts as another member.

In my point of view, even it's caused by professionals of our client, it's our responsibility to provide a solution for our client. How can we prevent such ocurrences?

I'm not experienced at all in Oracle. I'm a javascript and .net developer, so you can guess that I am quite at lost on this problem. But I wanted to do something beyond my scope, as most of the folks here are not really worried with this. We lose each month a good amount of time fixing this database; Removing duplicates manually.

Thanks!

Était-ce utile?

La solution

A simple log table and a standard script header and footer can help control database changes.

Add a table like this to your product:

create table script_log
(
    id              number,
    description     varchar2(4000),
    was_successful  varchar2(1) default 'N',
    create_date     date default sysdate,
    create_by       varchar2(30) default user,
    constraint script_log_pk primary key (id),
    constraint script_log_ck1 check (was_successful in ('Y', 'N'))
);

All changes should run using a standard tool and template. SQL*Plus is usually the best tool for database changes. It is not fancy, and it certainly has some quirks. But it can run anywhere and every Oracle professional knows it.

--Header, perhaps in a .SQL file that accepts parameters.
whenever sqlerror exit
variable script_id number
exec :script_id := 1;
insert into script_log(id, description) values(:script_id, 'First script.');
commit;

<add changes here>

--Footer, may also be in a .SQL file.
update script_log set was_successful = 'Y' where id = :script_id;
commit;
prompt Script done.

If someone tries to run the script a second time it will fail with this error:

*
ERROR at line 1:
ORA-00001: unique constraint (JHELLER.SCRIPT_LOG_PK) violated

A simple process and a little scripting can go a long way to help manage changes.

But don't be surprised if a simple solution like this is impossible at your company. For reasons I still don't understand this type of system is not part of the Oracle culture.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top