Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Difference between Insert and Append?

Posted on 2011-03-08
16
Medium Priority
?
2,257 Views
Last Modified: 2012-05-11
Difference between Insert and Append in Oracle?
0
Comment
Question by:Rao_S
  • 6
  • 6
  • 4
16 Comments
 

Author Comment

by:Rao_S
ID: 35070768
My Insert statement in my packaed procedure only produced the following error:
ORA-00001: unique constraint (AEHER01.PKEH_ER_ERRORS_HISTORY) violated
0
 
LVL 6

Expert Comment

by:anumoses
ID: 35070874
This error is swince the record already exists. So instead of insert in the table , do an update on the table for the existing record
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35070934
There is no 'append' per say in Oracle.  There is an append hint that causes new rows to be 'inserted' above the High-Water mark but I don't think that is what you mean by that term.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 6

Expert Comment

by:anumoses
ID: 35070959
append is  if you are using in a control file in sql loader?
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35071128
There is that but since they mention a package and procedure I have to assume this inst related to sql loader.
0
 

Author Comment

by:Rao_S
ID: 35071223
Why does the Sql Loader use 'APPEND'?
-- SQL Loader Control and Data File created by TOAD
-- Variable length, terminated enclosed data formattingLOAD DATA
INFILE *
BADFILE './ERRORS.BAD'
DISCARDFILE './ERRORS.DSC'
APPEND INTO TABLE AEHER01.TEH_ER_ERRORS
Fields terminated by ";" Optionally enclosed by '"'
(
  ERROR_LOG_PK NULLIF (ERROR_LOG_PK="NULL"),
  MESSAGE_UNIQUE_ID,
  etc............
)
BEGINDATA
310;"11D1DEF534EA1BE0:-57DC5FF7:12767585035:-7FD6";
------------------------------------------------
0
 
LVL 6

Expert Comment

by:anumoses
ID: 35071273
So its not package or procedure as mentioned earlier. Its sql loader control file.
Whats your question? why sql loader used append instead of update?

The APPEND keyword tells SQL Loader to preserve any pre-existing data in the table.
0
 
LVL 6

Expert Comment

by:anumoses
ID: 35071280
sending a link to know more on sql loader


http://psoug.org/reference/sqlloader.html
0
 

Author Comment

by:Rao_S
ID: 35071349
The error i get is when I execute a packed proc, but I was looking at a  Sql Loader file and I found an APPEND. Hence my question.
0
 
LVL 6

Expert Comment

by:anumoses
ID: 35071363
can you post the calling package procedure?
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35071463
You need to ask a single question per question.  The answer to 'APPEND' as it relates to sql loader is answered above.

Why you are getting unique constraint violation, although also already answered, should really be a new question.
0
 

Author Comment

by:Rao_S
ID: 35071479
The calling proc is pretty simple: Here it is:
PROCEDURE SP_LOAD_HISTORY   IS
     
   BEGIN
             BEGIN
                     --call the procedure to insert HISTORY by passing key field values.
                     SP_INSERT_HISTORY_PASS1 ;            
            END;
               BEGIN
                      --call the procedure to insert HISTORY by passing key field values.
                      SP_INSERT_HISTORY_PASS2 ;            
            END;
     
   END;
0
 

Author Comment

by:Rao_S
ID: 35071493
Here is the Packaged Spec:
CREATE OR REPLACE PACKAGE AEHER02.SPKG_ER_LOAD_HISTORY AS
/******************************************************************************
   NAME:       AEHER02.SPKG_ER_LOAD_HISTORY
   PURPOSE:

   REVISIONS:
   Ver        Date        Author           Description
   ---------  ----------  ---------------  ------------------------------------
   1.0        2/18/2011      CTZ6233       1. Created this package.
******************************************************************************/
 FUNCTION SF_GET_RETAINED_DAYS  (
      p_system_date                TIMESTAMP WITH LOCAL TIME ZONE,
      p_error_res_tmstp_date   TIMESTAMP WITH LOCAL TIME ZONE
      ) RETURN NUMBER;
   
   PROCEDURE SP_INSERT_HISTORY_PASS1 ;
       
    PROCEDURE SP_INSERT_HISTORY_PASS2 ;

   PROCEDURE SP_LOAD_HISTORY ;
     
   PROCEDURE SP_WRITE_LOG(
      p_error_log_pk                       NUMBER,
      p_message_unique_id             VARCHAR2,
      p_domain                               VARCHAR2,
      p_program_name                   VARCHAR2,
      p_error_res_tmstp                  DATE,
      p_entity_pk                            NUMBER,
      p_active_rentention_days        NUMBER,
      p_payload_retention_days       NUMBER,
      p_archive_retention_days        NUMBER,
      p_table_name                        VARCHAR2,
      p_rows_inserted                     NUMBER,
      p_rows_deleted                      NUMBER,
      p_error_message                   VARCHAR2) ;
     
     
END SPKG_ER_LOAD_HISTORY;

/
0
 
LVL 6

Accepted Solution

by:
anumoses earned 2000 total points
ID: 35071607
Answers for your question posted is already given in the above. Please close this question by choosing the answer best fits your need and then ask a new question for the package error.
0
 

Author Comment

by:Rao_S
ID: 35071849
The package has 4 procs and a function. Its a pretty simple package actually.
The calling proc calls pass1 proc and pass2 proc, they in turn call the function to check if the row has to be written to a history table. If it is wrriten to a history table then the row is deleted from the main table. And I capture all errors and log in a log table so that I can schedule this job and check the log table next day.
I added the /*+ APPEND*/ hint to the insert statement and am running the proc, (its going to take 1/2 hr to run)  lets see what happens!
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35071875
The APPEND hint does nothing to solve the unique constraint violation.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question