Create trigger before any DML or DDL operations on any schema objects

Dears,
I need to create a trigger on schema that fire before any DML or DDL operations on any object (table,view,. . . etc) in the schema.
Can i do this, like "BEFORE insert or update or delete or drop or truncate on SCHEMA" ?
Thanks & Regards,,

Dear Peter,_
Please, i need to say one thing before reading my below simple answers . . .
You must deal with any issue from others seriously and read it carefully_
Sorry, you haven't explained anything about your actual problem, we are still left to guessing.Not right, I was clear as i said the below notes:
1 - I need to create a trigger on schema that fire before any DML or DDL operations on any object.
2 - We have another simple application is connected also to DB and we must have this application but DB password is must written clear in some files and these files must be shared for business requirements.
Since I still do not understand your problem, I can only guess of the most relevant:After all of the above clarification, still do not understand . . . How !!!
1.9 Sweeping privileges. This is always a good exercise
2.10 Audit and Analyse User access. Who connects as what from where (And later maybe why).
3.8 Restrict Access from Specific Nodes OnlyYou are right but not valid in my issue.
3.1 Remove the passwords from scriptsIt seems that you did not read my replies carefully as I said before that DB password is must be written clear in some files and these files must be shared for business requirements.
Why not spend just a day to get some feeling of the ideas, and find the best match(es) for your situation.I am investigating in my issue a month ago and tried a lot of solutions but found that i will have to apply this trigger solution.
If you are looking for a short answer in a public forum, I am afraid you won't find it.
(At least not until we understand what you are trying to do, and why)I know exactly what i need and why. Read again my replies carefully and you will know also.
Not at allSure, you still do not understand because you did not read my replies carefully !
Dear All_
I already created the trigger to prevent any DML or DDL on any schema objects for specific users.
If all the users now have the super password, i can permit specific users to do (DML & DDL) and the others will not be able at all.
As a Challenge, i can say the super password now to the public and they will not be able to do any (DML & DDL) . . . I can say now, "I succeeded" :)
Really, thanks All for greatest support . . . Already i was benefited a lot from your advises.
Regards,

Similar Messages

  • Audit All DML and DDL on an Application Schema

    Hello;
    I have a requirement to audit all DML and DDL on an Application Schema (Lets say SCOTT). I have set:
    ALTER SYSTEM SET audit_trail = XML, EXTENDED scope=spfile; -- Want my audit log on the OS with Bind and SQL.
    ALTER SYSTEM SET AUDIT_SYS_OPERATIONS = TRUE scope=spfile; -- Want to audit sysdba and sysoper activity
    audit create session; -- Want to see both logins and failed logins
    How would I get all DML and DDL on an Application Schema (SCOTT)?
    I am using 11iR1 Standard Edition.

    Have look at system_privilege_map and find all the options you need to audit...
    or you can use the below script..
    SELECT 'audit ' ||LOWER(name) || ' by app_user;'
    FROM system_privilege_map;
    if you want to filter-out the one you have already audited, then use dba_priv_audit_opts ...
    Hope this info will be useful to you...
    Thanks,

  • Do we need to create or actiovate any system objects for ess mss applicatio

    Hi
       I am new to ESS MSS business packages.i know we need to activate 5 pairs of JCO destinations,
    do we need to create or activate any system objects ,because ess mss applications contains transactional iviews also
    how they will communicate.

    once you placed the portal content, the default system objetcs for ESS and MSS are delivered by SAP only, we need to configure the same like JCO destinations.,

  • Trigger to audit DML and DDL nor working

    Requirement: Application team complains that everyday within a fixed timeframe, 1 entry from a particular table is being deleted. They are unable to track it, which particular job is it doing it.
    DBA: We had 3 solutions: 1. AUDIT_TRAIL
    2. FGA
    3. Customized TRIGGER to track the DML and DDL.
    After discussion, option 3 has been implemented. Here is the code.
    DML Trigger
    =======
    CREATE OR REPLACE TRIGGER SLCPROD.STORE_TERM_ID_HST_TRG
    BEFORE INSERT OR UPDATE OR DELETE
    ON SLCPROD.STORE_TERM_ID FOR EACH ROW
    BEGIN
    IF UPDATING THEN
    INSERT INTO STORE_TERM_ID_HIST
    ( STR_NUM,
    TERM_ID,
    HOST_ENV,
    USR_TERMINAL,
    SESSION_USR,
    OS_USER,
    ACTION_DATE,
    ACTION_NAME)
    VALUES
    ( TRUNC(:OLD.STR_NUM)||','||:NEW.STR_NUM,
    TRUNC(:OLD.TERM_ID)||','||:NEW.TERM_ID,
    sys_context('USERENV', 'HOST'),
    sys_context('USERENV', 'TERMINAL'),
    sys_context('USERENV', 'SESSION_USER'),
    sys_context('USERENV', 'OS_USER'),
    SYSDATE,
    'UPDATE');
    ELSIF DELETING THEN
    INSERT INTO STORE_TERM_ID_HIST
    ( STR_NUM,
    TERM_ID,
    HOST_ENV,
    USR_TERMINAL,
    SESSION_USR,
    OS_USER,
    ACTION_DATE,
    ACTION_NAME)
    VALUES
    ( :OLD.STR_NUM,
    :OLD.TERM_ID,
    sys_context('USERENV', 'HOST'),
    sys_context('USERENV', 'TERMINAL'),
    sys_context('USERENV', 'SESSION_USER'),
    sys_context('USERENV', 'OS_USER'),
    SYSDATE,
    'DELETE');
    END IF;
    END;
    DDL Trigger
    ========
    CREATE OR REPLACE TRIGGER SLCPROD.STORE_TERM_ID_HST_TRG_TRUNC
    AFTER DDL ON DATABASE
    declare
    object_name varchar2(30);
    BEGIN
    select distinct ora_dict_obj_name into object_name from dual;
    if UPPER(object_name)= 'STORE_TERM_ID'
    then
    INSERT INTO STORE_TERM_ID_HIST
    ( STR_NUM,
    TERM_ID,
    HOST_ENV,
    USR_TERMINAL,
    SESSION_USR,
    OS_USER,
    ACTION_DATE,
    ACTION_NAME)
    VALUES
    ( 'NA',
    'NA',
    sys_context('USERENV', 'HOST'),
    sys_context('USERENV', 'TERMINAL'),
    sys_context('USERENV', 'SESSION_USER'),
    sys_context('USERENV', 'OS_USER'),
    SYSDATE,
    ora_sysevent);
    END IF;
    END;
    TABLE STORE_TERM_ID_HIST DESC
    =======================
    Name Null? Type
    STR_NUM CHAR(25)
    TERM_ID CHAR(25)
    HOST_ENV VARCHAR2(50)
    USR_TERMINAL VARCHAR2(50)
    SESSION_USR VARCHAR2(50)
    OS_USER VARCHAR2(50)
    ACTION_DATE DATE
    ACTION_NAME VARCHAR2(50)
    Though we have these triggers in place, still we can see that 1 record is getting deleted (do not know how as I haven't been able to track it) between 8 AM - 8:50 AM. We have verified it from COUNT and also know which particular record is getting deleted.
    We tried to see if any error logged due to these triggers in ALERT logs, but no error specific to it has been seen. We have tested the TRIGGERs using manuals queries, and they seem to be working fine.
    Could anyone please help what could be happening here? Or any better solution of resolving it.
    Thanks,
    Tapan
    Edited by: TapanKumar Saha on Mar 31, 2013 10:04 PM
    updated the code.

    Thank you all for all the help.
    My issue is resolved now. Here is the analysis:
    Our triggers (both for DML and DDL) were working earlier as well. However, it was not capturing the actions. We could see that last_ddl_date is being updated with the time when we are expecting the mischievous to happen. So, after having internal discussions, we concluded that "ALTER INDEX.." could also update the last_ddl_date. But it has nothing to do with the DELETE. However, to track the INDEX DDLs we added trigger on INDEX as well. Here is the modified code:
    DDL Trigger
    =======
    CREATE OR REPLACE TRIGGER SLCPROD.STORE_TERM_ID_HST_TRG_TRUNC
    AFTER DDL ON DATABASE
    declare
    object_name varchar2(30);
    BEGIN
    select distinct ora_dict_obj_name into object_name from dual;
    if UPPER(object_name)= 'STORE_TERM_ID'
    then
    INSERT INTO STORE_TERM_ID_HIST
    ( STR_NUM,
    TERM_ID,
    HOST_ENV,
    USR_TERMINAL,
    SESSION_USR,
    OS_USER,
    ACTION_DATE,
    ACTION_NAME)
    VALUES
    ( 'NA',
    'NA',
    sys_context('USERENV', 'HOST'),
    sys_context('USERENV', 'TERMINAL'),
    sys_context('USERENV', 'SESSION_USER'),
    sys_context('USERENV', 'OS_USER'),
    SYSDATE,
    ora_sysevent);
    elsif UPPER(object_name)= 'STORE_TERM_ID_PK'
    then
    INSERT INTO STORE_TERM_ID_HIST
    +( STR_NUM,+
    TERM_ID,
    HOST_ENV,
    USR_TERMINAL,
    SESSION_USR,
    OS_USER,
    ACTION_DATE,
    ACTION_NAME)
    VALUES
    +( 'NA',+
    +'NA',+
    sys_context('USERENV', 'HOST'),
    sys_context('USERENV', 'TERMINAL'),
    sys_context('USERENV', 'SESSION_USER'),
    sys_context('USERENV', 'OS_USER'),
    SYSDATE,
    ora_sysevent);
    END IF;
    END;
    It started tracking the TRUNCATE on the table.
    Also, we we increased the length of the data types for the temporary table to avoid any insertion errors. And finally put an INSERT trigger after seeing TRUNCATE DDLs. And we thus we resolved the issue.

  • How to Track the table using Trigger or any other Object

    Hi Folks
    I need to audit Inserts, deletions, updates  to inserted into other tracking table. I was planning on using a trigger to do this,
    Can you please help me how can I wright code for trigger for this. or else using any other object we can do this operation.
    can you please help me thanks in advance.
    Thank in advance.

    Also you can use an OUTPUT clause ( need to modify your DML operations)
    create table itest ( i int identity not null primary key, j int not null unique )
    create table #new ( i int not null, j int not null)
    insert into itest (j)
    output inserted.i, inserted.j into #new
    select o.object_id from sys.objects as o
    select * from #new
    drop table #new, itest;
    go
    The example below shows code that uses OUTPUT clause in UPDATE and DELETE statements to insert rows into an audit table.
    create table t ( i int not null );
    create table t_audit ( old_i int not null, new_i int null );
    insert into t (i) values( 1 );
    insert into t (i) values( 2 );
    update t
       set i  = i + 1
    output deleted.i, inserted.i into t_audit
     where i = 1;
    delete from t
    output deleted.i, NULL into t_audit
     where i = 2;
    select * from t;
    select * from t_audit;
    drop table t, t_audit;
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Creating trigger using database link

    I need to create the trigger from local server B using Dblink(whereas the dblink points to the remote server A)
    Action of the trigger:
    After every insertion of the record in the 'Table1' from the Remote DB Server A , the newly inserted record should parallely inserted into the 'Table 2' of the local server B
    Kindly help me out to do
    _ BY
    Rajan

    I tried to create the trigger but it throws like DDL operations are not allowed in the remote database.
    Following is the script, I have tried
    CREATE OR REPLACE TRIGGER ROUTE_TRIGGER AFTER INSERT ON ROUTEDECISION@DBLINK1
    FOR EACH ROW
    DECLARE
    BEGIN
    INSERT INTO routedecision_rptdb(a1,a2) values(:new.a1,:new2.a2);
    END;

  • During sync, itoons error message "User's iphone cannot be synced. You do not have enough access priviledges for this operation." Never happened before, any ideas what to do?  Checked and new computer is authorized.  Greg

    During sync, itoons error message "User's iphone cannot be synced.  You do not have enought access proviliedges for this operation".  Never happened before, any ideas what to do?  Checked and new computer is authorized.  Greg

    I hope this helps.    Not the easiest fix, but I suspect it will solve the problem.
    http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/itun es-privileges-error-with-windows-7/d616e06f-ecdd-4d34-8d7a-a9936a91ad6e

  • Create trigger not audited when run from sql developer Version 3.2.20.09

    Creating or editing a trigger is not being stored in the audit table when run from sql developer.
    Here is a sample script to show the issue:
    Grant Connect,create table,create trigger To testuser Identified By testuser;
    create table testuser.testtab(t1 number);
    Select Count(*) From Dba_Audit_Trail Where Owner='TESTUSER';
    CREATE OR REPLACE TRIGGER testuser.testtab_bi_trg BEFORE
      Insert
          ON testuser.testtab FOR EACH ROW
    begin
      null;
    end;
    Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';
    drop user testuser cascade;
    If I run the script from sql developer the CREATE TRIGGER statement does not get audited.
    If I run the script from sql plus or All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.
    If I edit the trigger from sql developer the CREATE TRIGGER statement does not get audited.
    If I edit the trigger from  All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.

    DoyleFreeman wrote:
    Not sure what you mean by "perform the audit".
    Have you tested my script? Does the "Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';" increment by 1 after each of the ddl statements or only after the Create table statement.
    Your question doesn't have ANYTHING to do with sql developer and should be posted in the Database General forum
    https://forums.oracle.com/community/developer/english/oracle_database/general_questions
    Yes - and it works just fine once you ENABLE AUDITING. Your scripIt  does NOT include the statements or code used to ENABLE auditing and, specifically, enable auditing for triggers.
    Auditing doesn't just 'happen'; you have to enable it and you have to specify any non-default auditing that you want to perform.
    Have you read any of the extensive documentation about auditing to learn how to use it?
    See the Database Security Guide
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm
    Also see 'Auditing Functions, Procedures, Packages, and Triggers
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm#BCGBEAGC
    And see the AUDIT statement in the SQL language doc for how to specify auditing of specific operations.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4007.htm
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    0
    audit create trigger by scott
    CREATE OR REPLACE TRIGGER emp_copy_bi_trg BEFORE
      Insert
          ON emp_copy FOR EACH ROW
    begin
      null;
    end;
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    1

  • ORA-30511: invalid DDL operation in system triggers

    Hi,
    I am calling a procedure in a Trigger.
    In that Procedure EXECUTE IMMEDIATE is used to CREATE a table.
    But when The Trigger is firing its giving Error as :ORA-30511: invalid DDL operation in system triggers
    Kindly any help will be needful for me

    user598986 wrote:
    Hi,
    I am calling a procedure in a Trigger.
    In that Procedure EXECUTE IMMEDIATE is used to CREATE a table.
    But when The Trigger is firing its giving Error as :ORA-30511: invalid DDL operation in system triggers[I thought I already explained it|http://forums.oracle.com/forums/message.jspa?messageID=3379456#3379683]. And again, granting privileges dynamically in a logon trigger is a very bad design. If you want to stick to it, you could schedule a job in trigger, as Timur suggested, however keep in mind, job runs asynchronously, so trigger will have to wait for the job to finish. Otherwise there might be a gap where session would not have privs granted yet.
    SY.

  • Require DML and DDL for basic tables

    Hello,
    I want to pursue my oracle certification within 2-3 months. Therefore, I am eager to create basic tables those would provide me holistic idea and basic practices before my real test. Could you provide me basic tables for example, employee table, department table, sales table etc.with DML and DDL details? I do create plethora of DB objects when I build systems for clients; however, additionally, I intend to practice concepts whatever I will acquire after going through oracle books before certification.
    Thanks!

    Here is the sample script i took it from HR & SH Schemas.
    host echo Building Oracle demonstration tables. Please wait.
    set termout off
    DROP TABLE EMP;
    DROP TABLE DEPT;
    DROP TABLE BONUS;
    DROP TABLE SALGRADE;
    DROP TABLE DUMMY;
    DROP TABLE ITEM;
    DROP TABLE PRICE;
    DROP TABLE PRODUCT;
    DROP TABLE ORD;
    DROP TABLE CUSTOMER;
    DROP VIEW SALES;
    DROP SEQUENCE ORDID;
    DROP SEQUENCE CUSTID;
    DROP SEQUENCE PRODID;
    CREATE TABLE DEPT (
    DEPTNO NUMBER(2) NOT NULL,
    DNAME VARCHAR2(14),
    LOC VARCHAR2(13),
    CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO));
    INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
    INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
    INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
    INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');
    CREATE TABLE EMP (
    EMPNO NUMBER(4) NOT NULL,
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4) CONSTRAINT EMP_SELF_KEY REFERENCES EMP (EMPNO),
    HIREDATE DATE,
    SAL NUMBER(7,2),
    COMM NUMBER(7,2),
    DEPTNO NUMBER(2) NOT NULL,
    CONSTRAINT EMP_FOREIGN_KEY FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO),
    CONSTRAINT EMP_PRIMARY_KEY PRIMARY KEY (EMPNO));
    INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,'17-NOV-81',5000,NULL,10);
    INSERT INTO EMP VALUES (7698,'BLAKE','MANAGER',7839,'1-MAY-81',2850,NULL,30);
    INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,'9-JUN-81',2450,NULL,10);
    INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,'2-APR-81',2975,NULL,20);
    INSERT INTO EMP VALUES (7654,'MARTIN','SALESMAN',7698,'28-SEP-81',1250,1400,30);
    INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,'20-FEB-81',1600,300,30);
    INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,'8-SEP-81',1500,0,30);
    INSERT INTO EMP VALUES (7900,'JAMES','CLERK',7698,'3-DEC-81',950,NULL,30);
    INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,'22-FEB-81',1250,500,30);
    INSERT INTO EMP VALUES (7902,'FORD','ANALYST',7566,'3-DEC-81',3000,NULL,20);
    INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,'17-DEC-80',800,NULL,20);
    INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,'09-DEC-82',3000,NULL,20);
    INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,'12-JAN-83',1100,NULL,20);
    INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,'23-JAN-82',1300,NULL,10);
    CREATE TABLE BONUS (
    ENAME VARCHAR2(10),
    JOB CHAR(9),
    SAL NUMBER,
    COMM NUMBER);
    CREATE TABLE SALGRADE (
    GRADE NUMBER,
    LOSAL NUMBER,
    HISAL NUMBER);
    INSERT INTO SALGRADE VALUES (1,700,1200);
    INSERT INTO SALGRADE VALUES (2,1201,1400);
    INSERT INTO SALGRADE VALUES (3,1401,2000);
    INSERT INTO SALGRADE VALUES (4,2001,3000);
    INSERT INTO SALGRADE VALUES (5,3001,9999);
    CREATE TABLE DUMMY (
    DUMMY NUMBER );
    INSERT INTO DUMMY VALUES (0);
    CREATE TABLE CUSTOMER (
    CUSTID NUMBER (6) NOT NULL,
    NAME VARCHAR2(45),
    ADDRESS VARCHAR2(40),
    CITY VARCHAR2(30),
    STATE VARCHAR2(2),
    ZIP VARCHAR2(9),
    AREA NUMBER (3),
    PHONE VARCHAR2(9),
    REPID NUMBER (4) NOT NULL,
    CREDITLIMIT NUMBER (9,2),
    COMMENTS LONG,
    CONSTRAINT CUSTOMER_PRIMARY_KEY PRIMARY KEY (CUSTID),
    CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0));
    CREATE TABLE ORD (
    ORDID NUMBER (4) NOT NULL,
    ORDERDATE DATE,
    COMMPLAN VARCHAR2(1),
    CUSTID NUMBER (6) NOT NULL,
    SHIPDATE DATE,
    TOTAL NUMBER (8,2) CONSTRAINT TOTAL_ZERO CHECK (TOTAL >= 0),
    CONSTRAINT ORD_FOREIGN_KEY FOREIGN KEY (CUSTID) REFERENCES CUSTOMER (CUSTID),
    CONSTRAINT ORD_PRIMARY_KEY PRIMARY KEY (ORDID));
    CREATE TABLE ITEM (
    ORDID NUMBER (4) NOT NULL,
    ITEMID NUMBER (4) NOT NULL,
    PRODID NUMBER (6),
    ACTUALPRICE NUMBER (8,2),
    QTY NUMBER (8),
    ITEMTOT NUMBER (8,2),
    CONSTRAINT ITEM_FOREIGN_KEY FOREIGN KEY (ORDID) REFERENCES ORD (ORDID),
    CONSTRAINT ITEM_PRIMARY_KEY PRIMARY KEY (ORDID,ITEMID));
    CREATE TABLE PRODUCT (
    PRODID NUMBER (6) CONSTRAINT PRODUCT_PRIMARY_KEY PRIMARY KEY,
    DESCRIP VARCHAR2(30));
    CREATE TABLE PRICE (
    PRODID NUMBER (6) NOT NULL,
    STDPRICE NUMBER (8,2),
    MINPRICE NUMBER (8,2),
    STARTDATE DATE,
    ENDDATE DATE);
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('96711', 'CA', '7844', '598-6609',
    'JOCKSPORTS',
    '100', '5000', 'BELMONT', '415', '345 VIEWRIDGE',
    'Very friendly people to work with -- sales rep likes to be called Mike.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('94061', 'CA', '7521', '368-1223',
    'TKB SPORT SHOP',
    '101', '10000', 'REDWOOD CITY', '415', '490 BOLI RD.',
    'Rep called 5/8 about change in order - contact shipping.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('95133', 'CA', '7654', '644-3341',
    'VOLLYRITE',
    '102', '7000', 'BURLINGAME', '415', '9722 HAMILTON',
    'Company doing heavy promotion beginning 10/89. Prepare for large orders during
    winter.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('97544', 'CA', '7521', '677-9312',
    'JUST TENNIS',
    '103', '3000', 'BURLINGAME', '415', 'HILLVIEW MALL',
    'Contact rep about new line of tennis rackets.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('93301', 'CA', '7499', '996-2323',
    'EVERY MOUNTAIN',
    '104', '10000', 'CUPERTINO', '408', '574 SURRY RD.',
    'Customer with high market share (23%) due to aggressive advertising.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('91003', 'CA', '7844', '376-9966',
    'K + T SPORTS',
    '105', '5000', 'SANTA CLARA', '408', '3476 EL PASEO',
    'Tends to order large amounts of merchandise at once. Accounting is considering
    raising their credit limit. Usually pays on time.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('94301', 'CA', '7521', '364-9777',
    'SHAPE UP',
    '106', '6000', 'PALO ALTO', '415', '908 SEQUOIA',
    'Support intensive. Orders small amounts (< 800) of merchandise at a time.');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('93301', 'CA', '7499', '967-4398',
    'WOMENS SPORTS',
    '107', '10000', 'SUNNYVALE', '408', 'VALCO VILLAGE',
    'First sporting goods store geared exclusively towards women. Unusual promotion
    al style and very willing to take chances towards new products!');
    INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE, NAME, CUSTID, CREDITLIMIT,
    CITY, AREA, ADDRESS, COMMENTS)
    VALUES ('55649', 'MN', '7844', '566-9123',
    'NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER',
    '108', '8000', 'HIBBING', '612', '98 LONE PINE WAY', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('101.4', '08-JAN-87', '610', '07-JAN-87', '101', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('45', '11-JAN-87', '611', '11-JAN-87', '102', 'B');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('5860', '20-JAN-87', '612', '15-JAN-87', '104', 'C');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('2.4', '30-MAY-86', '601', '01-MAY-86', '106', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('56', '20-JUN-86', '602', '05-JUN-86', '102', 'B');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('698', '30-JUN-86', '604', '15-JUN-86', '106', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('8324', '30-JUL-86', '605', '14-JUL-86', '106', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('3.4', '30-JUL-86', '606', '14-JUL-86', '100', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('97.5', '15-AUG-86', '609', '01-AUG-86', '100', 'B');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('5.6', '18-JUL-86', '607', '18-JUL-86', '104', 'C');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('35.2', '25-JUL-86', '608', '25-JUL-86', '104', 'C');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('224', '05-JUN-86', '603', '05-JUN-86', '102', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('4450', '12-MAR-87', '620', '12-MAR-87', '100', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('6400', '01-FEB-87', '613', '01-FEB-87', '108', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('23940', '05-FEB-87', '614', '01-FEB-87', '102', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('764', '10-FEB-87', '616', '03-FEB-87', '103', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('1260', '04-FEB-87', '619', '22-FEB-87', '104', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('46370', '03-MAR-87', '617', '05-FEB-87', '105', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('710', '06-FEB-87', '615', '01-FEB-87', '107', '');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('3510.5', '06-MAR-87', '618', '15-FEB-87', '102', 'A');
    INSERT INTO ORD (TOTAL, SHIPDATE, ORDID, ORDERDATE, CUSTID, COMMPLAN)
    VALUES ('730', '01-JAN-87', '621', '15-MAR-87', '100', 'A');
    INSERT INTO ITEM (QTY, PRODID, ORDID, ITEMTOT, ITEMID, ACTUALPRICE)
    VALUES ('1', '100890', '610', '58', '3', '58');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '1', '100861', '611', '45', '1', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '100', '100860', '612', '3000', '1', '30');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '1', '200376', '601', '2.4', '1', '2.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '20', '100870', '602', '56', '1', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '3', '100890', '604', '174', '1', '58');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '2', '100861', '604', '84', '2', '42');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '10', '100860', '604', '440', '3', '44');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '4', '100860', '603', '224', '2', '56');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '1', '100860', '610', '35', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '3', '100870', '610', '8.4', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '200', '200376', '613', '440', '4', '2.2');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '444', '100860', '614', '15540', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '1000', '100870', '614', '2800', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '20', '100861', '612', '810', '2', '40.5');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('150', '101863', '612', '1500', '3', '10');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '100860', '620', '350', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1000', '200376', '620', '2400', '2', '2.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('500', '102130', '620', '1700', '3', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ( '100', '100871', '613', '560', '1', '5.6');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('200', '101860', '613', '4800', '2', '24');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('150', '200380', '613', '600', '3', '4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '102130', '619', '340', '3', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '100860', '617', '1750', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '100861', '617', '4500', '2', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1000', '100871', '614', '5600', '3', '5.6');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '100861', '616', '450', '1', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '100870', '616', '140', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('2', '100890', '616', '116', '3', '58');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '102130', '616', '34', '4', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '200376' , '616', '24', '5', '2.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '200380', '619', '400', '1', '4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '200376', '619', '240', '2', '2.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('4', '100861', '615', '180', '1', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1', '100871', '607', '5.6', '1', '5.6');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '100870', '615', '280', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('500', '100870', '617', '1400', '3', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('500', '100871', '617', '2800', '4', '5.6');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('500', '100890', '617', '29000', '5', '58');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '101860', '617', '2400', '6', '24');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('200', '101863', '617', '2500', '7', '12.5');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '102130', '617', '340', '8', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('200', '200376', '617', '480', '9', '2.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('300', '200380', '617', '1200', '10', '4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('5', '100870', '609', '12.5', '2', '2.5');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1', '100890', '609', '50', '3', '50');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('23', '100860', '618', '805', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '100861', '618', '2255.5', '2', '45.11');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '100870', '618', '450', '3', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '100861', '621', '450', '1', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '100870', '621', '280', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '100871', '615', '250', '3', '5');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1', '101860', '608', '24', '1', '24');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('2', '100871', '608', '11.2', '2', '5.6');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1', '100861', '609', '35', '1', '35');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('1', '102130', '606', '3.4', '1', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '100861', '605', '4500', '1', '45');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('500', '100870', '605', '1400', '2', '2.8');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('5', '100890', '605', '290', '3', '58');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '101860', '605', '1200', '4', '24');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '101863', '605', '900', '5', '9');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('10', '102130', '605', '34', '6', '3.4');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('100', '100871', '612', '550', '4', '5.5');
    INSERT INTO ITEM ( QTY , PRODID , ORDID , ITEMTOT , ITEMID , ACTUALPRICE)
    VALUES ('50', '100871', '619', '280', '4', '5.6');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('4.8', '01-JAN-85', '100871', '3.2', '01-DEC-85');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('58', '01-JAN-85', '100890', '46.4', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('54', '01-JUN-84', '100890', '40.5', '31-MAY-84');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('35', '01-JUN-86', '100860', '28', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('32', '01-JAN-86', '100860', '25.6', '31-MAY-86');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('30', '01-JAN-85', '100860', '24', '31-DEC-85');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('45', '01-JUN-86', '100861', '36', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('42', '01-JAN-86', '100861', '33.6', '31-MAY-86');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('39', '01-JAN-85', '100861', '31.2', '31-DEC-85');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('2.8', '01-JAN-86', '100870', '2.4', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('2.4', '01-JAN-85', '100870', '1.9', '01-DEC-85');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('5.6', '01-JAN-86', '100871', '4.8', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('24', '15-FEB-85', '101860', '18', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('12.5', '15-FEB-85', '101863', '9.4', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('3.4', '18-AUG-85', '102130', '2.8', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('2.4', '15-NOV-86', '200376', '1.75', '');
    INSERT INTO PRICE (STDPRICE, STARTDATE, PRODID, MINPRICE, ENDDATE)
    VALUES ('4', '15-NOV-86', '200380', '3.2', '');
    CREATE INDEX PRICE_INDEX ON PRICE(PRODID, STARTDATE);
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('100860', 'ACE TENNIS RACKET I');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('100861', 'ACE TENNIS RACKET II');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('100870', 'ACE TENNIS BALLS-3 PACK');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('100871', 'ACE TENNIS BALLS-6 PACK');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('100890', 'ACE TENNIS NET');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('101860', 'SP TENNIS RACKET');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('101863', 'SP JUNIOR RACKET');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('102130', 'RH: "GUIDE TO TENNIS"');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('200376', 'SB ENERGY BAR-6 PACK');
    INSERT INTO PRODUCT (PRODID, DESCRIP)
    VALUES ('200380', 'SB VITA SNACK-6 PACK');
    CREATE SEQUENCE ORDID
    INCREMENT BY 1
    START WITH 622
    NOCACHE;
    CREATE SEQUENCE PRODID
    INCREMENT BY 1
    START WITH 200381
    NOCACHE;
    CREATE SEQUENCE CUSTID
    INCREMENT BY 1
    START WITH 109
    NOCACHE;
    CREATE VIEW SALES AS
    SELECT REPID, ORD.CUSTID, CUSTOMER.NAME CUSTNAME, PRODUCT.PRODID,
    DESCRIP PRODNAME, SUM(ITEMTOT) AMOUNT
    FROM ORD, ITEM, CUSTOMER, PRODUCT
    WHERE ORD.ORDID = ITEM.ORDID
    AND ORD.CUSTID = CUSTOMER.CUSTID
    AND ITEM.PRODID = PRODUCT.PRODID
    GROUP BY REPID, ORD.CUSTID, NAME, PRODUCT.PRODID, DESCRIP;

  • Rerunning script (DML and DDL) without ora-00001 and ora-00955 errors

    What is the best way to write a DML and DDL script so that it can be run multiple times without these ORA errors:
    ORA-00955: name is already used by an existing object
    ORA-00001: unique constraint (JILL.SYS_C00160247) violated
    I have just joined a product development company using SQL Server as there primary database. They have just completed a port to Oracle.
    Their product release upgrades (given to clients) include sql scripts with database changes (structure and data). They require that the client be able to rerun the scripts more than once with no errors. In SQL Server, the accomplish it this way.
    For DDL:
    if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MyTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    Begin
         CREATE TABLE [dbo].[MyTab] (
              [ID]int IDENTITY(1,1),
              [InvID] uniqueidentifier not null
    For DML:
    IF NOT EXISTS (SELECT 1 FROM [dbo].[mytab] WHERE [Name] = 'Smith' and [ID] = 3)
    BEGIN
    INSERT INTO [dbo].[mytab]
    ([ID] ,[Name]
    VALUES (3,'Smith')
    END
    I am tasked with duplicating this logic on the Oracle side. The only way I can think of so far is using plsql and checking for existence before every insert and create statement. The other options I thought of cannot be used in this case
    - "whenever sqlerror continue" - gives the same response for all errors. True errors should stop the code, so this is too risky.
    - "log errors into ... reject limit unlimited" on the insert - I thought this was my best solution until I found out that it doesn't support lobs.
    Do you know of any more elegant (and more efficient) solution other than plsql cursors to check for existence before running each insert/create?
    Any suggestions would be greatly appreciated.

    select table_name from user_tables will give you the table exist or not.
    all_tables/dba_tables
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10755/statviews_1190.htm#i1592091

  • CREATING TRIGGER

    create trigger DDL_GUARD_cact
    before DROP or TRUNCATE or DELETE
    on cidcb_cac
    begin
    raise_application_error( -20001, 'You are not allowed to DROP or TRUNCATE table in this schema. ' );
    end;
    I am try to build a triger so that no one can delete truncate or delete my table in schema but it is showing me error when i m executing it...
    ORA-30506: system triggers cannot be based on tables or views
    i think i am wrong in writing this query ...can someone guied me in creating this kind of trigger ...i am a user in oracle not administrator......
    so how can show error if someone try to do with my table in my schema like HR
    thanks in advance....:)
    using oracle 10.2g SE

    You cannot define a trigger of system level (drop, truncate) on a table since they are not DML, but DDL. These commands should be defined at schema level.
    Please, take a look to the trigger doc
    Nicolas.
    Re: Trigger ON DELETE or DROP or TRUNCATE
    Message was edited by:
    N. Gasparotto

  • No DDL operation on database.

    Dear all,
    I am using oracle 9i.
    I want that no user could perform DDL operation on database except sys user.
    How can I achive this.
    Please advice.
    Waiting for your reply.
    Regards,

    But my condition is this.I have schema say A.It have
    database objects like tables and views.
    I want that all users should have schema name and
    password.I just love questions like this. "I've got a completely insecure setup and my users are running amok. But I don't want to put proper procedures in place and I don't want to train my users. Please help me."
    Okay, here is the answer: triggers to prevent DDL.
    SQL> conn sys as sysdba
    Enter password: **********
    Connected.
    SQL> CREATE TRIGGER no_drop BEFORE DROP ON scott.SCHEMA
      2  BEGIN
      3     IF user != 'SYS'
      4     THEN
      5        RAISE_APPLICATION_ERROR(-20000, 'Naughty, naughty, naughty!');
      6     END IF;
      7  END;
      8  /
    Trigger created.
    SQL> conn scott/tiger
    Connected.
    SQL> drop table emp
      2  /
    drop table emp
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20000: Naughty, naughty, naughty!
    ORA-06512: at line 4
    SQL> Cheers, APC

  • Create trigger within PL/SQL

    I have a procedure that creates a trigger. When I execute the procedure I get an error: ORA-01031, however, when I copy and paste the create trigger command, it executes and will create the trigger without any problems. What is causing the 'insufficient privileges' error when it attempts to create it within a procedure?
    Here is the stream of commands SQLPlus that shows what I am getting:
    SQL> CREATE OR REPLACE PROCEDURE prc_create_trigger
    2 (Table_Name in varchar2)
    3 IS
    4 v_create_trigger VARCHAR2(4000);
    5 BEGIN
    6 v_create_trigger := 'CREATE OR REPLACE TRIGGER trg_pauls_table ';
    7 v_create_trigger := v_create_trigger || 'AFTER INSERT ON ' || table_name || ' ';
    8 v_create_trigger := v_create_trigger || 'REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW ';
    9 v_create_trigger := v_create_trigger || 'DECLARE ';
    10 v_create_trigger := v_create_trigger || ' v_text varchar2(20);';
    11 v_create_trigger := v_create_trigger || 'BEGIN';
    12 v_create_trigger := v_create_trigger || ' v_text := ''Inserted Row'';';
    13 v_create_trigger := v_create_trigger || ' dbms_output.put_line(v_text);';
    14 v_create_trigger := v_create_trigger || 'END;';
    15
    16 DBMS_OUTPUT.put_line(v_create_trigger);
    17
    18 --
    19 execute IMMEDIATE v_create_trigger;
    20 END;
    21 /
    Procedure created.
    SQL> exec prc_create_trigger('pauls_table');
    CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    varchar2(20);BEGIN v_text := 'Inserted Row';
    dbms_output.put_line(v_text);END;
    BEGIN prc_create_trigger('pauls_table'); END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "BAAN.PRC_CREATE_TRIGGER", line 20
    ORA-06512: at line 1
    SQL> CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    2 REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    3 varchar2(20);BEGIN v_text := 'Inserted Row';
    4 dbms_output.put_line(v_text);END;
    5 /
    Trigger created.
    I am wanting to do this because I need to create this trigger dynamically when a table has been created. This trigger is simply for testing the procedure.
    Thank you for your assistance.
    Paul

    Why does the application need to drop and re-create tables in the first place? What is the purpose of this "re-org"? If it accomplishes anything useful, it's likely that there is some flaw in the application architecture/ design/ implementation that could be fixed once to remedy whatever problem this drop & rebuild option attempts to solve. If there really is a need to reorganize a table regularly, could the application at least be modified to use one of the various approaches Oracle provides for this sort of thing?
    The "re-org" process you're describing is, at best, a hack. A trigger on the TABLES_TO_BE_REORGED table that creates triggers on whatever table name was deleted from this table is, at best, a hack. Layering one hack on top of another is likely to cause lots of pain.
    For one thing, a trigger cannot commit. But DDL implicitly commits before and after the DDL is executed. So you cannot create a trigger within another trigger. You could have a trigger that creates a job that later runs and creates the new trigger, but that's adding an extra layer of asynchronisity to a problem that is already likely over-engineered. You could also declare the trigger that creates the trigger to be an autonomous transaction, but that would cause horrible problems if the re-org process ever were to encounter and exception and have to roll back.
    Justin

  • Use of "DBA_OBJECTS" in "AFTER CREATE" Trigger

    Hi,
    We would like to store some extra information about our objects we have in the database. To do so we tought of the idea of creating a 'documenting' table containing an object_id that references to the object_id from the view dba_views.
    Now we want to automatically create a new record in our documenting table when a new object is created, in the first stage this should only contain the object_id
    To accomplish this we are using an 'AFTER CREATE' trigger, but when this trigger fires and the code searches for the new object_id in dba_objects, it does not return any records and generates an error. Likely because when the trigger is executed, the view is not yet updated?
    create or replace
    TRIGGER TRG_TEST
    AFTER CREATE ON SCOTT.SCHEMA
    DECLARE
    tmp VARCHAR2(50);
    BEGIN
    dbms_output.put_line(ora_dict_obj_name);
    select object_id
    into tmp
    from dba_objects
    where object_name = ora_dict_obj_name;
    dbms_output.put_line(tmp);
    END;
    Error report:
    ORA-04088: Fout bij uitvoering van trigger 'SCOTT.TRG_TEST'.
    ORA-01403: Geen gegevens gevonden.
    ORA-06512: in regel 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    It's in dutch, so I'll have a go at translating:
    Error report:
    ORA-04088: Exception while executing trigger 'SCOTT.TRG_TEST'.
    ORA-01403: No data found
    ORA-06512: in rule 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    Does anyone have an idea of how I can accomplish what I'm trying to do here.. Or maybe something I'm doing wrong?
    Thanks in advance!
    Davy

    What is "ora_dict_obj_name" defined as?
    Another option might be to setup a DBMS_SCHEDULER job to run the following insert
    firstly though, create the following table ;
    create document_table as (select * from dba_objects where rownum < 1)and then setup a DBMS_SCHEDULER job to run the following:
    begin
      insert into document_table
      (select dbo.*
       from   dba_objects    dbo
             ,document_Table dtb
       where  dbo.Object_ID = dtb.Object_ID(+)
       and    dtb.Object_ID is null);
       commit;
       exception
        when others then
          rollback;
          -- log a message somewhere with the error, i.e. SQLERRM
    end;
    /Note, I specified all columns, but you'll probably specify explicitly which column you require, in which case the CREATE table would change as well.
    Then you won't have a need for any trigger, and can better manage when you want your documentation to be updated.
    Another option might be to use COMMENT, which can be used on tables, views, materialized views, but won't cover all objects
    to the extent you might want.
    SQL> desc emp2
    Name                                                                                                  
    EMPNO                                                                                                 
    JOB                                                                                                   
    START_DATE                                                                                            
    SAL                                                                                                   
    DEPT                                                                                                  
    END_DATE                                                                                              
    SQL> comment on column emp2.sal is 'Existing Salary of employee as paid at most recent month end';

Maybe you are looking for

  • Lenovo S920 Wireless Problem.

    My smartphone wireless cannot power ON, Can somebody help? Lenovo S920. below is the screenshot of WIFI advance configuration.

  • Upload and Copy files using PLSQL.

    Hi All, Can UTL package can be used to upload any local data file to server? Or is there any in-built package which can be used to upload files to servers and copy files to another directory? Thanks in advance.

  • Okay, I have read some of the issues here

    Okay, I have read some of the issues here and I am scratching my head. I have my PC hard wired to a Linksys WRT G router and my Mac is connected wirelessly to it just fine. Now, my computers don't seem to see each other on the network. Pretend I am a

  • Now you see it, Now you don't? Mystery unmounted drives require recovery.

    My external Firewire 400 [seagate] drive is suddenly disappeared from the desktop after a reboot. When I go to use the Disk Utilities, it says it is an unformatted drive. I have "filesavage" and it sees the data but, ripping it does not save the file

  • Tcode SPAU  Objects in the Without Modification Assistant

    Hey guys, I´m working with tcode SPAU, i have some objects with red traffic light, i checked and i can see the active objects, do you know me what can i do for disapear de red light?