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

Similar Messages

  • ORA-00001 and ORA-06512 error on  DBMS_WM.ResolveConflicts

    We are getting unique constraint error in Production Database. We are able to merge most of the workspaces with no issues. One workspace is givign errors on merge.
    Here is the code
    begin
    dbms_wm.gotoworkspace('denialletterspoc_onmzpulp');
    dbms_wm.setdiffversions('denialletterspoc_onmzpulp','LIVE');
    dbms_wm.SetConflictWorkspace('denialletterspoc_onmzpulp');
    commit;
    DBMS_WM.BeginResolve('denialletterspoc_onmzpulp');
    DBMS_WM.ResolveConflicts(
    workspace => 'denialletterspoc_onmzpulp',
    table_name => 'MCM_MESSAGE',
    where_clause => ' id in (8403026,10134822,8259485,8259488,8426289,8426287,10186643,8426288) ',
    keep => 'CHILD'
    exception when others then
    DBMS_WM.RollbackResolve('denialletterspoc_onmzpulp');
    raise;
    end;
    ORA-00001: unique constraint (T2.MCM_MESSAGE_PK) violated
    ORA-06512: at line 16
    I looked at the date in XXX_lt tables and it does not look suspecious. Please help us understand
    ORA-00001 and ORA-06512 error.
    Amit Gangwar

    Hi, Ben
    Our OWM_VERSION is 10.2.0.4.3.
    I tried disable and enable constraint MCM_MESSAGE_PK. But didn't fix our issue.
    Split where clause from " id in (...) " syntax to " id = ... " syntax will reduce performance heavily. And I did some test that " id in (...) " syntax works well in our dev env.
    I opened our trace file and get below plsql block. When I perform it get same error with our original codes. Please notice the part of "forall wm_indx in WM_rowids.first .. WM_rowids.last execute immediate 'begin insert into T2.MCM_MESSAGE_lt ... ...", error occurred here. But if I change the "forall" syntax to normal " for ... loop" syntax then no error here. Can you give me some advice or suggestion?
    DECLARE
    WM_rowids wmsys.lt_ctx_pkg.rowidTabType;
    WM_rowids_vt wmsys.lt_ctx_pkg.rowidTabType;
    WM_curver wmsys.lt_ctx_pkg.int_tab;
    WM_vtRow wmsys.lt_ctx_pkg.int_tab;
    WM_nextver wmsys.lt_ctx_pkg.nextver_tab;
    WM_found integer := 0;
    BEGIN
    dbms_wm.gotoworkspace('denialletterspoc_onmzpulp');
    dbms_wm.setdiffversions('denialletterspoc_onmzpulp','LIVE');
    dbms_wm.SetConflictWorkspace('denialletterspoc_onmzpulp');
    /* update the auxilliary table of snapshots */
    /* These are rows in the current version that have already been resolved once */
    update T2.MCM_MESSAGE_aux st
    set (snapShotChild, snapShotParent, versionParent) =
    (select p.WM_childds, p.WM_parentds, p.WM_parentver
    from T2.MCM_MESSAGE_pkc p
    where p.ID = st.ID),
    value = '0',
    wm_opcode = 'CC'
    where st.versionChild = 614
    and (ID) in (select ID
    from T2.MCM_MESSAGE_pkc p
    where (id in (8403026,
    10134822,
    8259485,
    8259488,
    8426289,
    8426287,
    10186643,
    8426288)));
    select distinct WM_ridchild bulk collect
    into WM_rowids
    from T2.MCM_MESSAGE_pkc
    where (id in (8403026,
    10134822,
    8259485,
    8259488,
    8426289,
    8426287,
    10186643,
    8426288))
    and WM_childver != 614;
    if (WM_rowids.first is not null) then
    WM_found := 1;
    forall wm_indx in WM_rowids.first .. WM_rowids.last
    update T2.MCM_MESSAGE_lt
    set retireTime = wmsys.owm_9ip_pkg.activeTimeForDML,
    nextver = wmsys.lt_ctx_pkg.getNextVer(nextver,
    614,
    version,
    'denialletterspoc_onmzpulp',
    'CRS_LEAF',
    22)
    where rowid = WM_rowids(wm_indx)
    returning wmsys.lt_ctx_pkg.getCurNextVer bulk collect into WM_nextver;
    /* These are the rows that have not yet been resolved after the latest BeginResolve */
    forall wm_indx in WM_rowids.first .. WM_rowids.last execute immediate
    'begin insert into T2.MCM_MESSAGE_lt(ID,DPS_APPLICATION_ID,TYPE_ID,NAME,PRIVILEGED,CAMPAIGN_ID,TEXT,FILE_NAME,GRAPHIC_WIDTH,GRAPHIC_HEIGHT,DESCRIPTION,ACTIVE,INCLUDE_IN_LIBRARY,MESSAGE_FILTER_ID,OP_USER_ID,OP_WORKSPACE,OP_TIME,version,createtime,retiretime,nextver,delstatus,ltlock)
    (select t1.ID,t1.DPS_APPLICATION_ID,t1.TYPE_ID,t1.NAME,t1.PRIVILEGED,t1.CAMPAIGN_ID,t1.TEXT,t1.FILE_NAME,t1.GRAPHIC_WIDTH,t1.GRAPHIC_HEIGHT,t1.DESCRIPTION,t1.ACTIVE,t1.INCLUDE_IN_LIBRARY,t1.MESSAGE_FILTER_ID,t1.OP_USER_ID,t1.OP_WORKSPACE,t1.OP_TIME,614, wmsys.owm_9ip_pkg.activeTimeForDML, null,:1, sign(delstatus)*(abs(delstatus)+1),
    wmsys.lt_ctx_pkg.checkngetlock(''C'', t1.ltlock, t1.nextver, ''denialletterspoc_onmzpulp'', 0,
    ''MODIFY'', t1.version, t1.delstatus, 0, 1)
    from T2.MCM_MESSAGE_lt t1
    where t1.rowid = :2); end;'
    using WM_nextver(wm_indx),
    WM_rowids(wm_indx)
    end if;
    if (WM_found = 1) then
    wmsys.lt_ctx_pkg.update_modified_tables('T2',
    'MCM_MESSAGE',
    614,
    'denialletterspoc_onmzpulp',
    22);
    end if;
    if (WM_found = 1) then
    forall wm_indx in WM_rowids.first .. WM_rowids.last
    delete from T2.MCM_MESSAGE_aux
    where (ID) in (select ID
    from T2.MCM_MESSAGE_lt
    where rowid = WM_rowids(wm_indx))
    and childState = 'denialletterspoc_onmzpulp';
    end if;
    /* now insert new syncing information about these rows */
    execute immediate 'insert into T2.MCM_MESSAGE_aux (
    select ID,
    p.WM_childstate, p.WM_parentstate,
    p.WM_childds, 614, p.WM_parentds, p.WM_parentver, ''0'',''CC''
    from T2.MCM_MESSAGE_pkc p
    where ( id in (8403026,10134822,8259485,8259488,8426289,8426287,10186643,8426288) ) )';
    END;
    Thanks
    Amos

  • Regarding ORA-00001: unique constraint violation error

    Hi ,
    This is Venkat. I am new to OWB.
    When I run the mapping I am getting the ORA-00001: unique constraint violation error.
    My loading type is Update/Insert.
    My target table Primarykey is combination of 3 keys.
    Please give me the suggestions. It is very urgent.
    Thanks,
    Venkat

    1) If you can disable/drop the indexes on the table, you can load the data and then do a SQL query grouping by the PK/UI to show which rows have a count > 1 i.e. the duplicates.
    2) If you can't alter the target table, perhaps create a dummy copy of the table without pk/indexes and load to that and then do above query.
    3) Run the mapping via the debugger and set a breakpoint just before your target table and examine the data to see if you can spot the duplicates.
    4) Put a deduplicator into the mapping (just before target table), this may allow you to load data but doesn't solve the real problem as to why you have duplicates.
    Si

  • Hi... I am looking for an inexpensive app for my macbook pro that I can put pictures and videos together into a slideshow with captions and music WITHOUT a watermark and that also will burn the slideshow to a DVD in its own app. Help?

    Hi... I am looking for an inexpensive app for my macbook pro that I can put pictures and videos together into a slideshow with captions and music WITHOUT a watermark and that also will burn the slideshow to a DVD in its own app. Help?

    The issue with the A1400 is that like most economy compact cameras, they will not have very fast focus times in indoor lighting situations. Many people have gone to entry level DSLR's (Canon T3i) or micro 4/3 cameras. They are fairly expensive, but a late model refurbished T3i can sometimes be found with a kit lens for about $300.00. With Auto and scene modes, as well as full manual modes, these are very versatile cameras that focus very quickly, even in lower lighting situations. Canon is not really into the micro 4/3 cameras, instead they are focusing on the new G7x and G1x cameras, which are way out of your price range. The A720 is still available used at some places such as KEH camera, but you'll need to check often as their stock changes constantly. Obviously the DSLR's don't use AA batteries, but the T3i is good for about 600 photos (or more) per charge.
    My refurbished DSLR was practically brand new condition when I got it. I could not find any sign of wear at all, so I feel they are a real bargain. These are rugged cameras that are made to last. The A1400 is a $99.00 camera, so it's not intended for heavy usage, plus the image quality of a DSLR (even entry level) is far better than the A1400. That would be my recommendation.
    Steve M.

  • Skip ora-00001 and continue?

    Hi,
    I need to perform an update on a table like this:
    update myTable
    set myColumn = ltrim(myColumn, '0'); --trim all leading zeros
    I wnat this to perform on every row where it does not conflict with my unique constraint. I do not want to disable the constrataint because then I will end up with dupplicate records.
    Is it possible to create a script where the query executes on all rows where it does not conflict with any constrain? ...and simpy skip the confliction-rows?
    Thanks!
    (Oracle 10g)

    how shall i wite the query if I want to take the myOtherColumn into consideration? Following version should capture all possibilities (also when the trimmed pk is already there):
    SQL>  create table mytable (mycolumn, myothercolumn, mysecondothercolumn)
    as
    -- select '1', 'x' , 'y' from dual union all
    select '01', 'x' , 'y' from dual union all
    select '001', 'x', 'y2' from dual
    Table created.
    SQL>  alter table mytable add constraint mytable_pk primary key (mycolumn, myothercolumn)
    Table altered.
    SQL>  select * from mytable
    MYC M MY
    01  x y
    001 x y2
    2 rows selected.
    SQL>  update mytable t1
       set mycolumn = ltrim (mycolumn, '0')
    where rowid in (select max (rowid)
                       from mytable t2
                       group by ltrim (mycolumn, '0'),myothercolumn
                     having count (ltrim (mycolumn, '0')) > 1)
        and not exists (select null from mytable t2 where t2.mycolumn = ltrim(t1.mycolumn,0) and t1.myothercolumn=t2.myothercolumn)
    1 row updated.
    SQL>  select * from mytable
    MYC M MY
    01  x y
    1   x y2
    2 rows selected.

  • Ora-00001 and triggers

    I have a trigger that fires after tbl 1 col 9 update event.
    the trigger references old as old new as new on tbl 1.
    and proceeds to test old.value vs new.value
    it's goal is to insert a row into tbl 2 which are values from tbl 1.
    tbl 2 contains a unique constraint.
    I am trying to trap the condition DUP_VAL_ON_INDEX within the trigger and "log" the key thats failing, but continue. In this case the trigger is a hidden procedure from a called procedure whos goal is to update tbl 1 col 9 with a date.
    I have tryed this a number of ways.
    any help would be appreciated.
    tbl2 PK is a 6 part combo (julian_yr,julian_day,submit_typ,btch_num,id_num,adj_num)
    CREATE OR REPLACE TRIGGER tbl2
    AFTER UPDATE
    ON tbl1
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    begin
    if (:old.h_upld_dt is null and
    :new.h_upld_dt is not null) then
    if (:new.status_cd in ('EOK', 'MIS', 'DUP')) then
    insert into tbl2
    values (:new.julian_yr,
    :new.julian_day,
    :new.submit_typ,
    :new.btch_num,
    :new.id_num,
    :new.adj_num,
    sysdate, '', '', '');
    end if;
    end if;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    DBMS_OUTPUT.PUT_LINE ('tbl1 trigger into tbl2 failure: ' ||
    :new.julian_day ||
    :new.submit_typ ||
    :new.btch_num ||
    :new.id_num ||
    :new.adj_num ||
    sysdate);
    null;
    end;
    /

    there is always differnet ways to reach the goal.
    I was able to return the exception dup_val_on_index from the trigger back to the initiating procedure then deal with the issue there, which seems to work well. More testing should confirm.
    Thanks

  • ORA-00001 Unique constraint Violation Error

    We are upgrading our NW BW 7.01 java server to 7.3 and during the Downtime phase of the Installer, while running the Offline Migration, we are getting an error "EP-KM-BC: Unique Constraint Violation error: ORA-000001".  Unknown Object# (12xxxxxx) does not exist. We have one CI and two DI. Any help would be greatly appreciated.

    Hi Anil,
    You need to clear the data from the table
    1. SHD_AP_PROPVALUE
    2. SHD_KMC_AP_PROP
    3. SHD_AP_MC
    Repeat the phase and also follow the sapnote
    1873288 - RUN_OFFLINE_MIGRATION phase fails during SAP NetWeaver migration
    Also paste the logs of RUN_OFFLINE_MIGRATION phase.
    With Regards
    Ashutosh Chaturvedi

  • ORA-00001 - Unique Constraint error in Oracle forms 6i

    Hi,
    I am using Forms 6i. I have an issue while inserting records into a custom table.  Below is the functionality.
    When I check the check box,  and press the 'APPROVE' button, the record gets inserted into the custom table. But while inserting I am getting 'ora-00001-unique constraint violated error'.
    But the custom table doesn't have any data in it. (So the inserting record should not be a duplicate record).
    Any suggestions would be of great help.
    Thanks
    Deepti

    Is it a sql statement that is performing the insert, or are you using the native data block DML functionality in your form?  Secondly have you identified candidate columns that could be causing your issue?
    If you are using sql statement have you debugged to comfirm that you are not firing the same block of code more that once, and that if it is required to execute multiple times are you incrementing the sequence values that should be unique.
    Regards
    Q

  • 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,

  • 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;

  • Ora-06512  and ora-00001

    when our developer tries to insert few records in a table
    it throws error
    ora-00001 & ora-06512,
    when i tried to disable or drop the constraint indicated in the error 0ra-06512
    it throws ora-02431 - constraint not existing
    please guide us to solve this error.
    santhanam.

    I agree with Centinul, you probably do not want to get rid of the uniquenes enforced on the column. Better to find out why the developer is inserting duplicate records and fix that, or, if it is possible that you might get duplicate records in production, then develop a method of handling the error that properly meets your business needs.
    The ORA-00001 error can come from 3 sources. A PK constraint, a unique constraint and a unique index without a formal constraint.
    SQL> create table t (id number);
    Table created.
    SQL> create unique index t_unq on t(1d);
    Index created.
    SQL> insert into t values (1);
    1 row created.
    SQL> insert into t values (1);
    insert into t values (1)
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.T_UNQ) violatedDropping the constraint t_unq is not possible, I would need to drop the index. But I wouldn't, since in the vast majority of cases, the requirement for uniqueness is a business requirement, and not something put in to anoy developers.
    John

  • ORA-00001 When I try and create an interactive query/report

    Interactive report in APEX 3.2
    I have a query like this that does a country lookup
    based on the physical address and the mailing address.
    The query executes fine through SQL plus but when I try and create
    an interactive report I get
    ORA-00001: unique constraint (APEX_030200.WWV_FLOW_WORKSHEET_COLUMNS_UK2) violated
    Here's the query
    select     "TAX_VENDORS"."VENDOR_ID" as "VENDOR_ID",
         "TAX_VENDORS"."VENDOR_NAME" as "VENDOR_NAME",
         "TAX_COUNTRY"."ABBREVIATION" as "ABBREVIATION",
         "TAX_COUNTRY_1"."ABBREVIATION" as "ABBREVIATION"
    from     "TAX_COUNTRY" "TAX_COUNTRY_1",
         "TAX_COUNTRY" "TAX_COUNTRY",
         "TAX_VENDORS" "TAX_VENDORS"
    where "TAX_VENDORS"."PHYSICAL_COUNTRY"="TAX_COUNTRY"."TAX_COUNTRY_ID"
    and     "TAX_VENDORS"."MAILING_COUNTRY"="TAX_COUNTRY_1"."TAX_COUNTRY_ID"
    I've narrowed it down to the double lookup if you will of the country for the
    mail/physical address.
    Is this not allowed? Is there a work around?

    Thanks Tony
    A closer look at the constraint reveals this - so maybe it's seeing the TAX_COUNTRY_ID twice I would guess where the alias is not accounted for.
         CONSTRAINT "WWV_FLOW_WORKSHEET_COLUMNS_UK2" UNIQUE ("WORKSHEET_ID", "DB_COLUMN_NAME")
    Your query yielded me the same result
    select TV.VENDOR_ID as VENDOR_ID,
    TV.VENDOR_NAME as VENDOR_NAME,
    TC.ABBREVIATION as ABBREVIATION,
    TC_1.ABBREVIATION as ABBREVIATION
    from TAX_VENDORS TV
    JOIN TAX_COUNTRY TC ON (TV.PHYSICAL_COUNTRY = TC.TAX_COUNTRY_ID)
    JOIN TAX_COUNTRY TC_1 ON (TV.MAILING_COUNTRY=TC_1.TAX_COUNTRY_ID)

  • 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 avoid: ORA-01403 no data found AND ORA-00001

    Hi,
    below my code:
    CREATE TABLE TAB_TO_EM
      EM_NUMBER           VARCHAR2(32),
      NAME_FIRST       VARCHAR2(32),
      NAME_LAST        VARCHAR2(32),
      MAILBOX            VARCHAR2(32)
    ALTER TABLE TAB_TO_EM
    ADD (CONSTRAINT PK_EM_NUMBER PRIMARY KEY (EM_NUMBER));
    CREATE TABLE EM
      EM_ID            VARCHAR2(32),
      EM_NUMBER           VARCHAR2(32),
      NAME_FIRST       VARCHAR2(32),
      NAME_LAST        VARCHAR2(32),
      EMAIL            VARCHAR2(32)
    ALTER TABLE EM
    ADD (CONSTRAINT PK_EM_ID PRIMARY KEY (EM_ID));THE PRIMARY KEY EM_ID COMES FROM THE TAB_TO_EM TABLE LINKED IN THIS WAY:
    NAME_LAST||'_'||SUBSTR(NAME_FIRST,1,3)||'_'||SUBSTR(EM_NUMBER,-2)
    I created this procedure to insert a new EM_NUMBER into EM table:
    CREATE OR REPLACE PROCEDURE INS_NEW_RECORD IS
    ERR_NUM                          NUMBER;
    ERR_MSG                          VARCHAR2(300);
    V_COUNT                          NUMBER;
    V_EM_ID                          VARCHAR2(64);
          CURSOR A IS
          SELECT A.EM_NUMBER, A.NAME_FIRST, A.NAME_LAST, A.MAILBOX
          FROM TAB_TO_EM A;
    BEGIN
          FOR CUR_A IN A
      LOOP
                 SELECT COUNT(*)
                 INTO V_COUNT
                 FROM EM2 B
                 WHERE B.EM_NUMBER=CUR_A.EM_NUMBER;
                 IF V_COUNT = 0 THEN
                 -- here insert a new record
                              INSERT INTO EM2 (EM_ID, EM_NUMBER, NAME_FIRST,NAME_LAST, EMAIL)
                              VALUES (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2),
                              CUR_A.EM_NUMBER, CUR_A.NAME_FIRST,CUR_A.NAME_LAST, CUR_A.MAILBOX);
                 END IF;
      END LOOP;
    END INS_NEW_RECORD;Example of my table:
    Insert into TAB_TO_EM
       (EM_NUMBER, NAME_FIRST, NAME_LAST, MAILBOX)
    Values
       ('22333', 'AAAA', 'BBBB', 'XXXX');
    Insert into TAB_TO_EM
       (EM_NUMBER, NAME_FIRST, NAME_LAST, MAILBOX)
    Values
       ('11222', 'AAAA', 'BBBB', 'XXXX');
    Insert into TAB_TO_EM
       (EM_NUMBER, NAME_FIRST, NAME_LAST, MAILBOX)
    Values
       ('00122', 'AAAA', 'BBBB', 'XXXX');
    commit;
    execute INS_NEW_RECORD;
    ORA-00001: ORA-00001: unique constraint violated (PK_EM_ID)
    ORA-06512: a "INS_NEW_RECORD", line 25
    ORA-06512: a line 2I tried to modify my procedure:
    CREATE SEQUENCE AFM.SEQ_EM_ID
      START WITH 1
      MAXVALUE 999999999999999999999999999
      MINVALUE 1
      NOCYCLE
      NOCACHE
      ORDER;
    IF V_COUNT = 0 THEN
           --verify duplicate pkey
                 SELECT (NAME_LAST||'_'||SUBSTR(NAME_FIRST,1,3)||SUBSTR(EM_NUMBER,-2))
                 INTO V_EM_ID
                 FROM EM B
                 WHERE (NAME_LAST||'_'||SUBSTR(NAME_FIRST,1,3)||SUBSTR(EM_NUMBER,-2)) = (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2))
                 AND ROWNUM=1;
                 IF V_EM_ID = (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2)) THEN
                          INSERT INTO EM2 (EM_ID, EM_NUMBER, NAME_FIRST,NAME_LAST, EMAIL)
                          VALUES (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2)||'_'||SUBSTR ('000' || SEQ_EM_ID.NEXTVAL, -3),
                          CUR_A.EM_NUMBER, CUR_A.NAME_FIRST,CUR_A.NAME_LAST, CUR_A.MAILBOX);
                 ELSE
                              INSERT INTO EM2 (EM_ID, EM_NUMBER, NAME_FIRST,NAME_LAST, EMAIL)
                              VALUES (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2),
                              CUR_A.EM_NUMBER, CUR_A.NAME_FIRST,CUR_A.NAME_LAST, CUR_A.MAILBOX);
                 END IF;
          END IF;
    execute INS_NEW_RECORD;
    ORA-01403 no data foundI'd like to create a stored procedure with these conditions:
    IF em_id is duplicate insert new em_id= (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2)||'_'||SUBSTR ('000' || SEQ_EM_ID.NEXTVAL, -3)
    ELSE em_id= (CUR_A.NAME_LAST||'_'||SUBSTR(CUR_A.NAME_FIRST,1,3)||SUBSTR(CUR_A.EM_NUMBER,-2)
    How can I write my procedure correctly?
    Thanks in advance!

    1) What are you expecting this piece of code to do?
                 SELECT COUNT(*)
                 INTO V_COUNT
                 FROM EM B
                 WHERE B.EM_NUMBER=CUR_A.EM_NUMBER;My answer would be that i expect it to do nothing (unless i've misunderstood what you're doing up until now). You are making a new type of key in the EM table by frankensteining data elements from your tab_to_em table, so i would expect that code to always return 0. By the way, that's what we have a dup_val_on_index catch for, no need to read the table, you try your insert, if you dup a value, you take appropriate action.
    I guess the best way to proceed based on what you've provided would be 2 SQL statements.
    1) insert records where you cannot find a match in the target table
    2) insert records where you CAN find a match in the target table
    INSERT INTO EM (EM_ID, EM_NUMBER, NAME_FIRST,NAME_LAST, EMAIL)
    select
      A.NAME_LAST||'_'||SUBSTR(A.NAME_FIRST,1,3)||SUBSTR(A.EM_NUMBER,-2),
      A.EM_NUMBER,
      A.NAME_FIRST,
      A.NAME_LAST,
      A.MAILBOX
    from tab_to_em a
    where not exists
      select null
      from em b
      where b.NAME_LAST||'_'||SUBSTR(b.NAME_FIRST,1,3)||SUBSTR(b.EM_NUMBER,-2) = a.em_number
    INSERT INTO EM (EM_ID, EM_NUMBER, NAME_FIRST,NAME_LAST, EMAIL)
    select
      A..NAME_LAST||'_'||SUBSTR(A..NAME_FIRST,1,3)||SUBSTR(A..EM_NUMBER,-2)'_'||SUBSTR ('000' || SEQ_EM_ID.NEXTVAL, -3),
      A.EM_NUMBER,
      A.NAME_FIRST,
      A.NAME_LAST,
      A.MAILBOX
    from tab_to_em a
    where exists
      select null
      from em b
      where b.NAME_LAST||'_'||SUBSTR(b.NAME_FIRST,1,3)||SUBSTR(b.EM_NUMBER,-2) = a.em_number
    );This comes with the caveat that what you are doing is a REALLY bad idea. Really really really bad idea.
    The baddies are
    1) your choice for a 'primary key'
    2) using a sequence and then substring it
    3) this is from a business perspective, storing the same person multiple times!
    Now, i don't know your system or requirements, but i am speaking in general terms here, this seems like a all around bad idea and i would suggest you revisit the design.

  • Ora-00604 and ora-00001 when deploying mapping

    Hi,
    I have a problem when I want to deploy a mapping. I get the following errors: ora-00604 'error occurred at recursive SQL level 1' and ora-00001 'unique constraint violated (SYS.I_SOURCE1)'.
    I'm using owb 11.1.0.7.0.
    Can anybody help me to solve this?

    user9033344 wrote:
    Hi,
    I have a problem when I want to deploy a mapping. I get the following errors: ora-00604 'error occurred at recursive SQL level 1' and ora-00001 'unique constraint violated (SYS.I_SOURCE1)'.
    I'm using owb 11.1.0.7.0.
    Can anybody help me to solve this?Oracle Support.

Maybe you are looking for

  • Large export file when application contains a BI Publisher report

    Anyone have an idea why an application export file grows dramatically when a BI Publisher report template is added to an application? I have an application that was 400+ KB and went to 88+ MB just by adding one report query and RTF template. This res

  • Error message when updating itunes tv shows to ipod

    I purchased the orgignal 4 episode pilot of battlestar galactica from itunes. The first 2 episodes transfered to my ipod but i now get an error when it attempts to transfer the next. Attempting to copy to disk "my ipod" failed. The disk could not be

  • How insert Enterprise portal in Solution Manager

    Hi guys, Can anyone explane me how can I insert an enterprise portal in Solution Manager? I have execute this steps: - transaction smsy - landscape components -> Systems -> Create New System With Assistant - Choose SAP Enterprise portal After that I

  • New to Java cant get it to compile in msDOS

    Using SDK java 2 version 1.4.0. Checked my personal Computer folder types. In folders in windows 98 do java file types open with javac.exe or java.exe? Tried both. When I try to compile a simple tutorial HelloWorldApp.java , it gives me a message tha

  • My CommandButton calls PostContructs from other Managed Beans. Why?

    Hi, i have a big problem that i can't understand. I use a command Button who should call only one Managed Bean. But however it calls other Managed Beans too. How is it possible? my properties: Primfaces 2.1 Glassfish v3 jsf 2.0 Ejb 3.1 JPA - Toplink