Insert Handlers

Hi,
I have a requirement from my clients to handle the following event :
If an insert fails due to a primary key conflict (ORA-00001) then switch the INSERT to an UPDATE and re-apply. I have got most of the logic in place but it fails due to the lack of the old data. I have tried using the new data as the old data as well but it still throws a 01403 at me.
The handler has to be generic as there are literally hundreds of tables as well.
Any suggestions are appreciated.

Okay - got this working - requires a few things :
One - the handlers itself :
create or replace PACKAGE BODY "INSERT_ERRORS_PKG" AS
PROCEDURE insert_lcr (
   message IN SYS.ANYDATA,
   error_stack_depth IN NUMBER,
   error_numbers IN DBMS_UTILITY.NUMBER_ARRAY,
   error_messages IN EMSG_ARRAY )
  IS
    any_data    SYS.ANYDATA;
    lcr         SYS.LCR$_ROW_RECORD;
    retValue    PLS_INTEGER;
    apply_name  VARCHAR2(30);
    errlog_rec  tex_error_log%ROWTYPE ;
    newvals    SYS.LCR$_ROW_LIST;
    oldvals    SYS.LCR$_ROW_LIST;
    colname    VARCHAR2(255);
    coldata    SYS.ANYDATA;
    isPK       NUMBER;
  BEGIN
   -- If we have a uniqueness constraint (2290,1) or mismatch/missing (1403) or DDL mismatch on nullable (1400, 1401)
    IF error_numbers(1) IN ( 2290, 1 ) THEN
     any_data := DBMS_STREAMS.GET_INFORMATION('CONSTRAINT_NAME');
     retValue := any_data.GetVarchar2(errlog_rec.text);
       errlog_rec.resolution := 'UPDATE';
    ELSIF error_numbers(1) IN (1400, 1401) THEN
     errlog_rec.resolution := 'SCHEMA_INS';
    ELSE
     errlog_rec.text := NULL ;
     errlog_rec.resolution := 'UPDATE';
    END IF ;
    -- Get the name of the sender and the name of the apply process
    any_data       := DBMS_STREAMS.GET_INFORMATION('SENDER');
    retValue       := any_data.GETVARCHAR2(errlog_rec.sender);
    apply_name     := DBMS_STREAMS.GET_STREAMS_NAME();
    -- access the LCR and set the logging records
    retValue := message.GETOBJECT(lcr);
    errlog_rec.object_name := lcr.GET_OBJECT_NAME() ;
    errlog_rec.command_type := lcr.GET_COMMAND_TYPE() ;
    errlog_rec.errnum := error_numbers(1) ;
    errlog_rec.errmsg := error_messages(1) ;
    IF error_numbers(1) NOT IN (1, 1400, 1401) THEN
      errlog_rec.text := 'Reapplied as UPDATE' ;
    ELSE
      IF error_numbers(1) IN (1) THEN
        errlog_rec.text := 'Forced UPDATE' ;
      ELSE
        errlog_rec.text := 'Record DROPPED' ;
      END IF;
    END IF;
    -- now update the logging table
    INSERT INTO buftex.tex_error_log
    (error_date,object_name,apply_name,sender,command_type,resolution,errnum,errmsg,text,lcr, lcr_old)
    VALUES (
      SYSDATE,
      errlog_rec.object_name,
      apply_name,
      errlog_rec.sender,
      errlog_rec.command_type,
      errlog_rec.resolution,
      errlog_rec.errnum,
      errlog_rec.errmsg,
      errlog_rec.text,
      lcr.GET_VALUES('new', 'n'),
      lcr.GET_VALUES('old')
   commit;
    -- If we don't have a unique field violation then proceed
    IF error_numbers(1) NOT IN (1400, 1401) THEN
      -- added
      newvals := lcr.GET_VALUES('new', 'y');
      oldvals := lcr.GET_VALUES('new', 'y');
      --lcr.GET_SOURCE_DATABASE_NAME(),
      construct_row_lcr(
        source_dbname  =>  lcr.GET_SOURCE_DATABASE_NAME(),
        cmd_type       =>  'UPDATE',
        obj_owner      =>  lcr.GET_OBJECT_OWNER(),
        obj_name       =>  errlog_rec.object_name,
        old_vals       =>  oldvals,
        new_vals       =>  newvals,
        apply_name     =>  apply_name);
    END IF;
  END insert_lcr ;
END insert_errors_pkg;
/Then, you MUST set the following up for the tables to avoid errors :
DECLARE
  sqltext varchar2(3000);
CURSOR tbl_cur IS
SELECT table_name
  FROM all_tables
  WHERE owner = 'OWNER'
  and table_name like ('%');
BEGIN
  FOR x IN tbl_cur
  LOOP
   sqltext := 'DECLARE cols DBMS_UTILITY.NAME_ARRAY; BEGIN cols(1) := ''MODIFY_DATE''; DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER(object_name => ''BUFTEX.' || x.table_name || ''',method_name => ''OVERWRITE'',  resolution_column => ''MODIFY_DATE'', column_list => cols); END;';
   execute immediate sqltext;
  END LOOP;
END;
/Presto - test by setting the TAG to something other then NULL, insert a record in the target. Go to the source, make sure the TAG is NULL and insert the same record - you get a nice error message in the error table and the record in the target is updated.
Have fun
John

Similar Messages

  • Multiple processing of the recon events

    Hello, my friends.
    I have a terrible issue and i hope, that you could help me to solve it.
    My system info is:
    Solaris OS 10
    Weblogic 10.3
    IDM 9.1.0.2 bp12
    I perform trusted recon with SAP HRMS (it doesn't metter, becouse it happens every recon).
    Thus i get two cases:
    1. When event is linked and all pre insert handlers (adapters) executed without errors or exceptions. In this case everything is ok and user is created.
    2. Event is recieved, but there are some errors during it processing (some of pre-insert adapters throws an exception).
    In this case i get default error (ERROR [XELLERATE.JMS] Processing Reconciliation Message with ID 3725 failed.)
    But after that, the processing of event didn't stop and continues more and more times and it don't going to finish.
    So, more and more times it throws the pre-insert adapter exception and the error, that i mentioned before. And the only way to stop it is closing the event.
    Any ideas? What the reason of this issue? May be something with JMS queue?
    Thanks in advance, Dimitry.

    There is a schedule taks which re-processes all the recon events in the Event Received state. It automatically runs unless explicitly disabled.
    Just disable this Schedule Task -> Resubmit Reconciliation Event and you should be good

  • How to use symbols in a loaded swf

    I want to load a swf file in flex as application with embed
    tag and then create instance of its class. I want to use symbols
    within this swf i.e. to load dynamically those symbols when needed
    and play with it. is it possible in flex builder 3? If yes then how
    and if not then how can it be done? Any suggestion is
    appriciated.

    Hello,
    using that page as guide:
    http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/events/Uncau ghtErrorEvent.html#includeExamplesSummary
    (last sample on where to insert handlers) what about:
    <s:SWFLoader id="swfLoader" init="swfLoaderInitHandler(event)" source="B.swf"/>
    and:
    protected function swfLoaderInitHandler(event:Event):void
         if(!swfLoader.content) return;
         swfLoader.content.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAU GHT_ERROR,
              uncaughtErrorHandler);
    protected function uncaughtErrorHandler(errorEvent:UncaughtErrorEvent):void
         if(errorEvent.error is Error)
              var e:Error = errorEvent.error as Error;
              // my error is 1009 - it is expected here
              const NULL_ERROR:uint = 1009;
              if(e.errorID == NULL_ERROR)
                   errorEvent.preventDefault();
                   Alert.show(e.errorID+" "+e.message);
              // else fall through
         // else fall through
    B is supposed to fail:
    private var emptyObject:Object = null;
    public function B()
         flash.utils.setTimeout(throwErrorNow, 100);
    protected function throwErrorNow():void
         emptyObject.numericValue();
    regards,
    Peter

  • [svn:fx-3.x] 12301: Clean up lastSystemManager reference when SWFLoader unloads a SWF.

    Revision: 12301
    Revision: 12301
    Author:   [email protected]
    Date:     2009-11-30 14:52:14 -0800 (Mon, 30 Nov 2009)
    Log Message:
    Clean up lastSystemManager reference when SWFLoader unloads a SWF.
    When SWFLoader unloads itself null out SystemManager.lastSystemManager reference if the reference is the content it loaded. This will prevent SWFLoader leak reports when simply loading and unloading a swf.
    Move the removeInitSystemManagerCompleteListener() code before we unload because the contentLoaderInfo is destroyed by the time we get the unload message.
    Add code to prevent double loading.
    QE notes: None.
    Doc notes: None.
    Bugs: SDK-18076
    Reviewer: Alex
    Tests run: checkintests, MarshallPlan, components/SWFLoader
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-18076
    Modified Paths:
        flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/controls/SWFLoader.as

    Hello,
    using that page as guide:
    http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/events/Uncau ghtErrorEvent.html#includeExamplesSummary
    (last sample on where to insert handlers) what about:
    <s:SWFLoader id="swfLoader" init="swfLoaderInitHandler(event)" source="B.swf"/>
    and:
    protected function swfLoaderInitHandler(event:Event):void
         if(!swfLoader.content) return;
         swfLoader.content.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAU GHT_ERROR,
              uncaughtErrorHandler);
    protected function uncaughtErrorHandler(errorEvent:UncaughtErrorEvent):void
         if(errorEvent.error is Error)
              var e:Error = errorEvent.error as Error;
              // my error is 1009 - it is expected here
              const NULL_ERROR:uint = 1009;
              if(e.errorID == NULL_ERROR)
                   errorEvent.preventDefault();
                   Alert.show(e.errorID+" "+e.message);
              // else fall through
         // else fall through
    B is supposed to fail:
    private var emptyObject:Object = null;
    public function B()
         flash.utils.setTimeout(throwErrorNow, 100);
    protected function throwErrorNow():void
         emptyObject.numericValue();
    regards,
    Peter

  • Insert and update command types in dml handlers

    Hi,
    I have been setting up streams in Oracle 9.2.0.4.
    I have been writing dml handlers for a table 'LARGE_INSERT_CLONE' in the 'SQUID' schema.
    My requirement is as follows.
    1. If a record is inserted in the table 'LARGE_INSERT_CLONE' in the source database, a record must be inserted in the
    'LARGE_INSERT_CLONE_INS' table in the destination database.
    2. If a record is updated for the first time in the table 'LARGE_INSERT_CLONE' in the source database, a record must be inserted in the 'LARGE_INSERT_CLONE_UPD' table in the destination database. Upon subsequent updates in the table 'LARGE_INSERT_CLONE' in the source database, the appropriate record must be updated in the 'LARGE_INSERT_CLONE_UPD' table in the destination database.
    To incorporate this, I have set up streams on the 'LARGE_INSERT_CLONE' table at the source and destination databases.
    The structure of the table is
    CREATE TABLE LARGE_INSERT_CLONE (
    CLONE_ID NUMBER (15) primary key,
    LIBRARY_ID NUMBER (15) NOT NULL,
    CLONE_NAME VARCHAR2 (80) NOT NULL,
    CLONE_ALIAS VARCHAR2 (80),
    ESTIMATED_SIZE NUMBER (12,3),
    CHROMOSOME VARCHAR2 (2),
    CYTO_LOCATION VARCHAR2 (10),
    COMMENTS VARCHAR2 (255))
    The structure of the tables LARGE_INSERT_CLONE , LARGE_INSERT_CLONE_INS and LARGE_INSERT_CLONE_UPD are the same.
    I have set up dml handlers as follows. Having done so, supplemental log group has been created on each column of the table
    LARGE_INSERT_CLONE at the source database.
    BEGIN
    DBMS_APPLY_ADM.SET_DML_HANDLER(
    object_name => 'squid.LARGE_INSERT_CLONE',
    object_type => 'TABLE',
    operation_name => 'INSERT',
    error_handler => false,
    user_procedure => 'strmadmin.DMLLARGE_INSERT_CLONE',
    apply_database_link => null);
    END;
    BEGIN
    DBMS_APPLY_ADM.SET_DML_HANDLER(
    object_name => 'squid.LARGE_INSERT_CLONE',
    object_type => 'TABLE',
    operation_name => 'UPDATE',
    error_handler => false,
    user_procedure => 'strmadmin.DMLLARGE_INSERT_CLONE',
    apply_database_link => null);
    END;
    CREATE OR REPLACE PROCEDURE DMLLARGE_INSERT_CLONE(in_any IN SYS.ANYDATA) IS
    lcr SYS.LCR$_ROW_RECORD;
    old_values SYS.LCR$_ROW_LIST;
    new_values SYS.LCR$_ROW_LIST := null;
    rc PLS_INTEGER;
    old_no SYS.AnyData;
    command varchar2(10);
    no_found char(1) := 'N';
    res number;
    num number;
    tn VARCHAR2(61);
    BEGIN
    rc := in_any.GETOBJECT(lcr);
    command := lcr.GET_COMMAND_TYPE();
    old_values := lcr.GET_VALUES('OLD');
    new_values := lcr.GET_VALUES('NEW');
    IF command = 'UPDATE' THEN
    old_no := lcr.GET_VALUE('old','CLONE_ID');
         tn := old_no.GETTYPENAME();
         if tn = 'SYS.NUMBER' then
         res := old_no.GETNUMBER(num);
         end if;
         BEGIN
         select DISTINCT 'Y'
         into no_found
         from squid.LARGE_INSERT_CLONE_UPD
         WHERE CLONE_ID = num;
         lcr.SET_OBJECT_NAME('LARGE_INSERT_CLONE_UPD');
         EXCEPTION
         WHEN OTHERS THEN
         lcr.SET_COMMAND_TYPE('INSERT');
         lcr.SET_OBJECT_NAME('LARGE_INSERT_CLONE_UPD');
         END;
         ELSIF command = 'INSERT' THEN
         lcr.SET_COMMAND_TYPE('INSERT');
         lcr.SET_OBJECT_NAME('LARGE_INSERT_CLONE_INS');
         END IF;
         LCR.EXECUTE(true);
    END;
    Having done so, when i perform dml operations, the following is the outcome.
    1. Upon insert of a record, the record is appropriately inserted in LARGE_INSERT_CLONE_INS table.
    2. Upon updating the record, as per the requirements, a record must be inserted in LARGE_INSERT_CLONE_UPD table, but i get the following error.
    ORA-01400: cannot insert NULL into ("SQUID"."LARGE_INSERT_CLONE_UPD"."CLONE_ID")
    I tried printing the new values the lcr holds, they seem to be correct. but the record is not inserted.
    Could anyone tell me where the operation fails.
    Thanx.
    Trupti

    well the fields have values.
    they are not null.
    now if i add the following.
    lcr.add_column('new',clone_id,old_no);
    and update a column say clone_name
    then the record is inserted with the clone_id and clone_name values. The rest is null.
    My question is if the lcr has the new set of values, why does it insert null into the columns. ?

  • Error handlers inserting into exception queue?

    Hi,
    Im currently writing a PL/SQL procedure that handles specific apply errors. The errors that i'm not interested in I would like to remain in the exception queue. How can I insert the LCRs into the exception queue?
    Cheers,
    Warren

    I think i've realised that if you want the lcr to end up in the exception queue you have to call its execute sub-program.
    e.g.
    lcr.execute(true);
    If execute is not called the apply error is effectively deleted/forgotten.

  • OIM pre-insert event handlers

    Hello
    I've created a pre-insert event handler to generate a random password and email it to user manager. If reconciliation failed, the inserted record is rolled back but the event still generate and send password 3 times. Is there any solution for that?
    If I divide that event in 2 parts; 1 pre-insert to generate the password and the other post-insert to send it , I will not have access to the user password!
    Thanks in advance

    Actually I was wrong, OIM allows access to user's password in PLAIN TEXT. Keeping in mind that it will mostly be the password for all user's resources, this is such a critical security risk.

  • Error while inserting data in Forms10G using TEXT_IO

    Dear all i am using 10g Forms.
    I am using Text_io to read the text file and putting into table and again reading the tables and putting into another text file .
    I was testing in 3 tables which is the same copy of the original table but only the name is different .
    But after testing when i change the table name to Original table name , it is not inserting for 1 table .
    What could be the reason ?
    I already check the columns and all , everything is current .
    Edited by: Sandy on Sep 14, 2010 5:39 PM

    Please use tags when posting your code over here and format it proper so others can read it more easily.
    e.g.
    [code]
    procedure my_proc is
      num_data number;
    begin
      select 1
      into num_data
      from dual;
      if num_data = 2 then
    end;
    [/code]
    Are you sure you are getting here:
    [code]
    INSERT INTO MU_PAY_OLB(RECORD_TYPE,LOAD_NO,TRAN_AMT,OLB_CODE,ACCT_NO,BEN_NAME,PAY_DTL,MACCS_IND)
    VALUES(lval,l_val,DTL_AMT,lbank,DTL_BEN_AC_NO,DTL_BEN_NM,Null,'N');
    [/code]
    Also: only trap the exceptions you expect, and not ALL exceptions e.g.
    [code]
    begin
      INSERT INTO MU_PAY_OLB(RECORD_TYPE,LOAD_NO,TRAN_AMT,OLB_CODE,ACCT_NO,BEN_NAME,PAY_DTL,MACCS_IND)
      VALUES(lval,l_val,DTL_AMT,lbank,DTL_BEN_AC_NO,DTL_BEN_NM,Null,'N');
    exception
      when dup_val_on_index then
        --do whatever you need to do in that case
    end;
    [/code]
    Maybe your tablespace is full and thus your insert statement fails? You need to inform the user so he/she can inform the DBA.
    and at last this one:
    [code]
    WHEN Others THEN
      Text_IO.Fclose(in_file);
    END;
    [/code]
    You are hiding all possible exceptions; it might be a numeric or value error as the line you are reading is longer then your line buffer, or $add_any_possible_exception_here. You only close the file and behave like nothing ever happened. If you need to close your text file in any case it should look like this:
    [code]
    exception
      when others then
        if text_io.is_open(in_file) then
          text_io.fclose(in_file);
        end if;
        raise;
    end;
    [/code]
    By that you are closing the file if necessary (the exception might occur after you closed the file and closing it again will cause another exception), and reraise your exception so it can be processed by the higher element in the call stack; maybe your calling procedure expects some exceptions in your procedure too and handles them respectively. If no one in the call stack expects the exception and traps it, it finds it's way to the end user (who is you in that case). If it throws an exception take a look where it happens and take actions.
    So remove your when others exceptions and look if some other exceptions occur. By now there might occur an exceptions but as you are hiding them all we and you have no clue about if, when, why and where it happens. Remove / replace the exception handlers as shown and you should get a clue about if, when, why and where.
    cheers                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is there better way to write SQl Insert Script

    I am running out of ideas while working on one scenario and thought you guys would be able to guide me in right way.
    So, the scenario is I have a Table table1 table1(fieldkey, DisplayName, type) fieldkey - pkey   This table have n number of rows. The value of fieldkey in nth row is n. So if we have 1000 record, then the last row has a fieldkey = 1000.
    Below is my sample data.
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1001, 'COfficer',100);
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1002, 'PData',100);
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1003, 'EDate',100);
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1004, 'PData',200);
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1005, 'EDate',300);
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    (1006, 'Owner',400);This way of inserting the row with hardcoded value of fieldkey was creating the problem when the same table was used by other developer for their own new functionality.
    So, I thought of using the max(fieldkey) +1 from that table and use it in my insert script. This script file runs every time during software installation.
    I thought of using count to see if the row with same displaytype and type exists in that table or not. If exisits do not insert new row, if not insert new row.
    It looks like i will have to query the count statement everytime before I insert the row.
    select max(fieldkey) +1 into ll_fieldkey from table1
    select count(*) into ll_count from table1 where display ltrim(upper(name)) = 'COFFICER' and type =100)
    if ll_count >0 then
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    ( ll_fieldkey, 'COfficer',100);
    ll_fieldkey := ll_fieldkey +1
    end if;
    select count(*) into ll_count from table1 where display ltrim(upper(name)) = 'PData' and type =100)
    if ll_count >0 then
    Insert into table1 (FIELDKEY,DISPLAYNAME,TYPE) values
    ( ll_fieldkey, 'PData',100);
    ll_fieldkey := ll_fieldkey +1
    end if;
    ... and so on for all the insert statement. So, i was wondering if there is some better way to handle this situation of inserting the data.
    Thank you

    Hi !
    For check if the same display name and type already exists in table i would use Unique Key , but then again instead of if statement you should code some exception handlers. ... Hm .. Unque key is by may opinion better solution as
    codeing checks .
    For faster inserts that is , smaller code .. if there is no rules for values and the values are fixed , in any case you have to do this 100 inserts. If you can "calculate" values then maybe you can figure out some code .. but effect will be the same as hundred insert stetements one after another .. Procedure with this 100 inserts is not so bad solution.
    You can fill with values a nested table and then use forall ... save exceptions insert and with above mentioned UK , maybe this will be better.
    T
    Edited by: ttt on 10.3.2010 13:01

  • Axis SOAP Adapter - Setting MIME headers for attachements (Handlers?)

    Hello,
    I need to know if/how it is possible to set the individual MIME headers of the parts making up a multipart/related SOAP message using only standard Axis Handlers e.g. "com.sap.aii.axis.xi.XI30DynamicConfigurationHandler" (as described in the Axis FAQ in Note 1039369).
    I know I can insert transport headers  using "com.sap.aii.axis.xi.XI30DynamicConfigurationHandler", but I can't see a way of setting a MIME header for, say, the first part (i.e. the SOAP part) or the second part (e.g. an attachement). Is this possible without writing your own Axis handler? The Axis FAQ, in "Advanced usage question 31" implies that you can set MIME Headers but only shows an example of setting the transport header.
    I am using the SOAP Adapter to send a message comprising and XML message (in the SOAP body) and a PDF document (as an attachement). The external company this is being sent to requires that we have specific values for the "Content-Id" MIME header in each part of the multipart/related document. This is why I need to understand if we can do this without writing our own Axis Handler.
    Incidentally, I have tried to write a custom Axis Handler but couldn't get PI to find it after deployment. I did this by inserting my JAR file in the "com.sap.aii.adapter.lib.sda" (as per Notes 1039369 / 1138877) and then using JSPM. After deployment, though, when I tried to start the SOAP Adapter I got the following error in the RWB: "failed to initialize: org.apache.axis.ConfigurationException: java.lang.ClassNotFoundException: com.hp.gerryaxis.GerryAxis..." (my class was called "GerryAxis" and I placed this in package "com.hp.gerryaxis"). I'm not an experienced Java programmer (my background is in ABAP), so if anyone can suggest whey I'm getting this error, I'd be very grateful (for example, could my choice of package be causing the problem?).
    Thanks for your help.

    I went ahead and wrote a simple bespoke Axis Handler. By invoking this from the standard "HandlerBean" in the module processor of my communication channel, I was able to overwrite and set new MIME headers in the Attachment Parts of my SOAP Message. I was also able to change the contents of the SOAP Envelope; for example, I found I could easily delete the SOAP Header. However, I've encountered a problem when I try and update the MIME headers of the SOAP Part i.e. the Part of the multipart/related message containing the SOAP Envelope.
    Does anyone know why I can't seem to change the MIME headers of the SOAP Part?
    The Axis API calls I used were as follows:
    (1) To update the MIME headers of attachements in my SOAP message:
    (a) Message = MessageContext.getCurrentMessage()
    (b) Iterator = Message.getAttachments()
    (c) AttachmentPart = Iterator.getNext()
    (d) AttachmentPart.setMimeHeader(name, value)
    This works.
    (2) To update the MIME headers of the SOAP (root) Part:
    (a) Message = MessageContext.getCurrentMessage()
    (b) SOAPPart = Message.getSOAPPart()
    (c) SOAPPart.setMimeHeader(name, value)
    This DOESN'Twork - the MIME headers of the SOAP Part never change.
    (3) To update the SOAP Envelope (delete the SOAP Header):
    (a) Message = MessageContext.getCurrentMessage()
    (b) SOAPPart = Message.getSOAPPart()
    (c) SOAPEnvelope = SOAPPart.getEnvelope()
    (d) SOAPHeader = SOAPEnvelope.getHeader()
    (e) SOAPHeader.removeContents()
    This works.
    I just don't understand why the call to SOAPPart.setMimeHeader() doens't work when I try and insert new MIME headers to the SOAP Part (e.g. "Content-Name") or when I try and change existing MIME headers there (e.g. "Content-ID"). I don't get any errors.
    The code of my handler is:
    @(#)GerryAxis.java       
    Set MIME headers in the SOAP and specified attachment part of a message
    package com.hp.handlers;
    import org.apache.axis.handlers.BasicHandler;
    import org.apache.axis.AxisFault;
    import org.apache.axis.attachments.AttachmentPart;
    import org.apache.axis.Message;
    import org.apache.axis.MessageContext;
    import java.util.Iterator;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.rpc.handler.soap.SOAPMessageContext;
    The <code>GerryAxis</code> handler class sets MIME headers.
    <p>
    This handler accepts the following parameters:
    <ul>
    <li><b>name</b>: Name of header
    <li><b>value</b>: Value for header
    <li><b>attachment</b>: Attachment number
    </ul>
    public class GerryAxis extends BasicHandler {
      /* (non-Javadoc)
    @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
      public void invoke(MessageContext msgContext) throws AxisFault {
        int i=0;
        boolean found = false;
        AttachmentPart ap = null;
        javax.xml.soap.SOAPPart sp = null;
        StringBuffer debug = new StringBuffer();
        try {
          // The MIME header change is controlled from the parameters "name", "value", "attachment" which  are
          // set in the module processor as parameters.
          String name  = (String)getOption("name");
          String value = (String)getOption("value");
          String attachment  = (String)getOption("attachment");
          Message msg = msgContext.getCurrentMessage();
          // Get the SOAP Part (the part holding the SOAP Envelope
          sp = msg.getSOAPPart();
          if (sp == null)
              debug.append("getSOAPPart returned <null> / ");
          // Set a MIME header in the SOAP Part - THIS DOES NOT WORK - WHY?     
          sp.setMimeHeader(name,value);
          // Remove the SOAP Header for the Envelope - this works fine
          SOAPEnvelope se = sp.getEnvelope();
          SOAPHeader sh = se.getHeader();
          sh.removeContents();
          // For debugging - writes some debuggin information to a "DEBUG" MIME header in the first Attachement Part
          debug.append("name = " + name +" / ");
          debug.append("value = " + value +" / ");
          debug.append("attachment = " + attachment + " / ");
          debug.append("getMimeHeader for SOAPPart returned " + sp.getMimeHeader(name)[0] + " / ");
          debug.append("getContentId for SOAPPart returned " + sp.getContentId() + " / ");
          // Update the specified attachement's MIME header - this works fine
          Iterator it = msg.getAttachments();
          while (it.hasNext()) {
            i++;
            ap = (AttachmentPart) it.next();
            if (i == new Integer(attachment).intValue()) {
              found = true;
              break;
          if (found) {
            ap.removeMimeHeader(name);
            ap.setMimeHeader("DEBUG",debug.toString());
            ap.setMimeHeader(name,value);
          msg.saveChanges();
        catch (Exception e) {
          throw AxisFault.makeFault(e);
    Thanks
    Edited by: Gerry Deighan on Oct 3, 2010 10:27 PM

  • The last insert in this procedure not inserting, logic of flow is right?

    Here is the code:
    { PROCEDURE prAddDATU (p_EXPCLLI            IN VARCHAR2,
    p_EXPIP IN VARCHAR2,
    p_EXPName IN VARCHAR2,
    p_EXPAddress IN VARCHAR2,
    p_EXPCity IN VARCHAR2,
    p_EXPState IN VARCHAR2,
    p_COPhoneNumber IN VARCHAR2,
    p_WCCLLI IN VARCHAR2,
    p_DialIn IN VARCHAR2,
    p_DialOut IN VARCHAR2,
    p_EXPRR IN VARCHAR2,
    p_PowerFuse IN VARCHAR2,
    p_HDFFrame IN VARCHAR2,
    p_PGTCFrame IN VARCHAR2,
    p_NTTFrame IN VARCHAR2,
    p_ColanRR IN VARCHAR2,
    p_ColanJack IN VARCHAR2,
    p_PollInterval IN NUMBER,
    p_LeadNPA IN NUMBER,
    p_EXPComments IN VARCHAR2,
    p_OwnerID IN NUMBER,
    p_LRNNumbers IN VARCHAR2,
    p_MaintBegin IN VARCHAR2,
    p_MaintEnd IN VARCHAR2,
    p_EXPPort IN NUMBER,
    p_LRNChecked IN VARCHAR2,
    p_LRNFacilityCode IN VARCHAR2,
    p_IsPrimaryAddress IN VARCHAR2,
    p_RTUTypeId IN NUMBER,
    p_SiteName IN VARCHAR2,
    p_HostExpIds IN VARCHAR2)
    IS
    v_DATUID NUMBER;
    v_HostExpId NUMBER;
    v_HostExpIds VARCHAR2 (200);
    v_LRN VARCHAR2 (30);
    v_LRNS VARCHAR2 (400);
    v_LRNActive CHAR (1);
    v_LRNSActive VARCHAR2 (20);
    v_LRNFacilityCode CHAR (2);
    v_LRNSFacilityCode VARCHAR2 (300);
    v_pos1 NUMBER;
    v_pos2 NUMBER;
    v_pos3 NUMBER;
    v_pos4 NUMBER;
    BEGIN
    SELECT DATU_EXP_UNIT_INFO_SEQ.NextVal INTO v_DATUID FROM DUAL;
    INSERT INTO TT_DATU_EXP_UNIT_INFO VALUES (v_DATUID, p_OwnerID, p_EXPName, p_EXPAddress, p_EXPCity, p_EXPState, p_COPhoneNumber, p_WCCLLI, p_EXPCLLI, p_EXPIP, p_EXPPort, p_DialIn, p_DialOut, p_EXPRR, p_PowerFuse, p_HDFFrame, p_PGTCFrame, p_NTTFrame, p_ColanRR, p_ColanJack, p_PollInterval, p_LeadNPA, NULL, p_EXPComments, p_MaintBegin, p_MaintEnd, p_IsPrimaryAddress, p_RTUTypeId, p_SiteName, Sysdate);
    -- Add New DATU in the TT_DATU_EXP_STAGING and TT_DATU_EXP_UNIT_INFO tables
    INSERT INTO TT_DATU_EXP_STAGING VALUES (v_DATUID, p_EXPCLLI, SysDate);
    -- Add New DATU in the TT_DATU_EXP_ALARM_INFO table with ALARM_TYPE = 'G0 - Staging'
    INSERT INTO TT_DATU_EXP_ALARM_INFO VALUES (v_DATUID, SysDate, 'G0', SysDate);
    -- Add RTU to Hosts
    v_HostExpIds := p_HostExpIds;
    v_pos1 := INSTR(v_HostExpIds, ',', 1);
    WHILE v_pos1 > 0
    LOOP
    v_HostExpId := TRIM(SUBSTR(v_HostExpIds, 1, v_pos1 - 1));
    IF v_HostExpId IS NOT NULL
    THEN
    INSERT INTO TT_HOST_SATELLITE VALUES (v_HostExpId, v_DATUID);
    END IF;
    v_HostExpIds := SUBSTR(v_HostExpIds, v_pos1 + 1, LENGTH(v_HostExpIds));
    v_pos1 := INSTR(v_HostExpIds, ',', 1);
    END LOOP;
    -- if LRN maps are entered add records in DATU_LRN_MAP
    v_LRNS := p_LRNNumbers;
    v_LRNSActive := p_LRNChecked;
    v_LRNSFacilityCode := p_LRNFacilityCode;
    v_pos1 := INSTR(v_LRNS, ',', 1);
    v_pos2 := INSTR(v_LRNSActive, ',', 1);
    v_pos3 := INSTR(v_LRNSFacilityCode, ',', 1);
    WHILE v_pos1 > 0
    LOOP
    v_LRN := TRIM(SUBSTR(v_LRNS, 1, v_pos1 - 1));
    v_LRNActive := TRIM(SUBSTR(v_LRNSActive, 1, v_pos2 - 1));
    v_LRNFacilityCode := TRIM(SUBSTR(v_LRNSFacilityCode, 1, v_pos3 - 1));
    IF v_LRN IS NOT NULL
    THEN
    INSERT INTO TT_DATU_LRN_MAP VALUES (v_LRN, v_DATUID, v_LRNActive, v_LRNFacilityCode);
    END IF;
    v_LRNS := SUBSTR(v_LRNS, v_pos1 + 1, LENGTH(v_LRNS));
    v_LRNSActive := SUBSTR(v_LRNSActive, v_pos2 + 1, LENGTH(v_LRNSActive));
    v_LRNSFacilityCode := SUBSTR(v_LRNSFacilityCode, v_pos3 + 1, LENGTH(v_LRNSFacilityCode));
    v_pos1 := INSTR(v_LRNS, ',', 1);
    v_pos2 := INSTR(v_LRNSActive, ',', 1);
    v_pos3 := INSTR(v_LRNSFacilityCode, ',', 1);
    END LOOP;
    COMMIT;
    END prAddDATU;
    The problem here is the last insert into TT_datu_lrn_map table shows no insert at all.
    Any guru can help, please.
    Thanks,

    I used an error table like the other post a ton. If you take a few minutes to review Handling Exceptions in PL/SQL you will be happy you did.
    You can add other columns to the table and add debug comments like 'Insert 1" in 'Insert 2' etc.
    BEGIN
    INSERT
    EXCEPTION
    WHEN ZERO_DIVIDE THEN
    END;
    There are several standard errors you can trap for example: (So you can trap for more than one at a time)
    -- Only one of the WHEN blocks is executed.
    WHEN CASE_NOT_FOUND -- ORA-06592
    dbms_output.put_line('Missing the else clause ');
    WHEN CURSOR_ALREADY_OPEN -- ORA-06511
    dbms_output.put_line('Close cursor first before reopening. ');
    WHEN DUP_VAL_ON_INDEX -- ORA-00001
    dbms_output.put_line('Attempt to store a duplicate value or values in a database column.');
    WHEN INVALID_CURSOR -- ORA-01001
    dbms_output.put_line('You tried to reference a cursor that does not yet exist. ');
    WHEN INVALID_NUMBER -- ORA-01722
    dbms_output.put_line('An attempt is made to convert a character string into a number failed ');
    WHEN LOGIN_DENIED -- ORA-01017
    dbms_output.put_line('Username is not a recognised username or that the password is incorrect ');
    WHEN NO_DATA_FOUND -- ORA-01403
    dbms_output.put_line('All records have been returned from the SQL query. ');
    WHEN ROWTYPE_MISMATCH -- ORA-06504
    dbms_output.put_line('Number and/or types of columns in a query does not match declared return type of a result set ');
    WHEN SYS_INVALID_ROWID -- ORA-01410
    dbms_output.put_line('Query for table for which there is no such row ');
    WHEN TOO_MANY_ROWS -- ORA-01422
    dbms_output.put_line('SELECT INTO statement returns more than one row ');
    WHEN VALUE_ERROR -- ORA-06502
    dbms_output.put_line('Unable to convert value. ');
    WHEN ZERO_DIVIDE THEN -- handles 'division by zero' error
    dbms_output.put_line('Company must have had zero earnings.');
    pe_ratio := null;
    WHEN OTHERS THEN -- handles all other errors
    dbms_output.put_line('Some other kind of error occurred.');
    END; -- exception handlers and block end here
    I hope this helps you.
    MS

  • Using System::ErrorDescription in Insert statement

    Hello,
    I want to insert System::ErrorDescription to store the error in the customized log table. When I use the following statement, it does not insert anything. What am i doing wrong. Please advice.
    create table dbo.load_err(load_err_id integer(PK),load_err_Dtl,loadtime)
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
     @[System::ErrorDescription] ,
    getdate())
    I see the row inserted but nothing in the Load_ERR_DTL column.

    Where are you using the insert statement? The ErrorDescription  variable is only available inside OnError,OnWarning and OnInformation event handlers
    http://msdn.microsoft.com/en-IN/library/ms141788.aspx
    Also you need to use insert statement as below
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
    getdate())
    and map parameter0 to  @[System::ErrorDescription] in parameters tab
    another way is to set SQLSourceType
    as Variable and set a variable for the query with below expression as
    "INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,'" +
    @[System::ErrorDescription] + "',
    getdate())"
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Using package call in insert statement.

    insert into
    as_portal_credentials_test
    values('id', 'key','expid',UTL_RAW.CAST_TO_RAW('zTMwv2.[[?~d'))                                                                                                                                                                                                               

    Where are you using the insert statement? The ErrorDescription  variable is only available inside OnError,OnWarning and OnInformation event handlers
    http://msdn.microsoft.com/en-IN/library/ms141788.aspx
    Also you need to use insert statement as below
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
    getdate())
    and map parameter0 to  @[System::ErrorDescription] in parameters tab
    another way is to set SQLSourceType
    as Variable and set a variable for the query with below expression as
    "INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,'" +
    @[System::ErrorDescription] + "',
    getdate())"
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Errors with post-insert trigger

    I had a POST-INSERT TRIGGER here.but i encountered some problems.can someone help me with the errors?
    begin
         insert into user_acct
         userid_n, user_m, coy_c, contact_n, emp_n,
         work_loc_c, curr_passwd_t, prt_f, indv_pc_f, pc_deploy_c,      
         ext_email_addr_t, other_na_sys_t, status_c, status_rmk_t, upd_d)
         values
         (:user_acct.userid_n, :user_acct.user_m, :user_acct.coy_c, :user_acct.contact_n, :user_acct.emp_n,
         :user_acct.work_loc_c, :user_acct.curr_passwd_t, :user_acct.prt_f, :user_acct.indv_pc_f, :user_acct.pc_deploy_c,                
         :user_acct.ext_email_addr_t, :user_acct.other_na_sys_t, :user_acct.status_c, :user_acct.status_rmk_t,                
         :user_acct.upd_d);
         exception
              when others then
                   clear_message;
                   Message('Insertion of Applicant Particulars failed');
                   SYNCHRONIZE;
                   RAISE Form_Trigger_failure;
    end;
    begin
    insert into user_acct_na_detl
         na_sys_c)
         values
         (:na_sys_cd.na_sys_c);
         exception
              when others then
                   clear_message;
                   Message('Insertion of Non-Application failed');
                   SYNCHRONIZE;
                   RAISE Form_Trigger_failure;
    end;
              when others then
                   null;      
    end;     
    the error:
    Error 103 at line 31, column 3
    Encountered the symbol 'WHEN' when expecting one if the following:
    begin declare end exception exit for goto if loop mod null
    pragma raise return select update while <an identifier>
    <a double-quoted delimited-identifier><a bind variable><<
    close current delete fetch lock insert open rollback
    savepoint set sql commit<a single-quoted SQL string>
    The symbol "exception"was substituted for "WHEN" to continue
    Error 103 at line 2, column 1
    Encountered the symbol "END"

    i delete the "END" already but when i compile again, i encountered some error again.
    Error 370 at line 27, column
    OTHERS handler must be last among the exception handlers of a block
    Error 0 at line 1, column 1
    Statement ignored

  • ALV Insert Button Drop Down

    Hi all,
    Can any body please tell me that in ALV grid, how can i get the drop down for insert button in the tool bar with options "Add 1", "Add 2" ... inserting 1, 2 or 3 lines??
    Thanks in advance,
    Kulwant

    1) define following macro
    DEFINE toolbar_funcs.
       CLEAR ls_toolbar.
        MOVE 0 TO ls_toolbar-butn_TYPE.
        MOVE &1 TO ls_toolbar-function.
        MOVE SPACE TO ls_toolbar-disabled.
        MOVE &2 TO ls_toolbar-icon.
        MOVE &3 TO ls_toolbar-quickinfo.
        APPEND ls_toolbar TO e_object->mt_toolbar.
    END-OF-DEFINITION.
    2)  in the class definition
      EVENTS: user_command.
        METHODS:
         on_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING
              e_ucomm
              sender,
         on_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING
              e_object
              e_interactive.
    3) define the handlers
    SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
    4) in the implementation part  code the functions you've given your  buttons
    for example
    METHOD on_user_command.
      break-point 1.
        CASE e_ucomm.
          WHEN 'EXIT'.
            LEAVE PROGRAM.
          WHEN 'EXCEL'.
            CALL METHOD me->download_to_excel.
          WHEN 'SAVE'.
          WHEN 'PROC'.
            CALL METHOD me->process.
          WHEN 'REFR'.
            CALL METHOD me->refresh.
        ENDCASE.
      ENDMETHOD.  "on_user_command
    In the toolbar method  --use YOUR buttons and functions
    Using the macro in step 1) means you have to write a lot less code. Some people don't like macros but in this case we are using it for pure code generation and not complex processing so it's (IMO) still OK.
    METHOD on_toolbar.
    customize this section with your own Buttons
    When a button is pressed method ON_USER_COMMAND is entered
       toolbar_funcs 'EXIT'  icon_system_end            'Click2exit'.
       toolbar_funcs 'SAVE'  icon_system_save           'Savedata'.
       toolbar_funcs 'EDIT'  icon_toggle_display_change 'Edit data'.
       toolbar_funcs 'PROC'  icon_businav_process       'Process'.
       toolbar_funcs 'EXCEL' icon_xxl                   'Excel'.
       toolbar_funcs 'REFR'  icon_refresh               'Refresh'.
       ENDMETHOD.                    "on_toolbar
    Change the toolbar button type to what you want. It's all in the ALV documentation. The code above uses standard rather than drop down buttons but the process is the same.
    The permitted values and types can be found by looking at the values for domain  TB_BTYPE.
    I think you want 2 (Menu type button).
    Change this line in the macro
    MOVE 0 TO ls_toolbar-butn_TYPE.
    For a menu set the type to 2.
    Include the menu handler in the class definition
    handle_menu_button
            FOR EVENT menu_button OF cl_gui_alv_grid
                IMPORTING e_object e_ucomm,
    SET HANDLER z_object->handle_menu_button FOR grid1.
    Add your choices when you click the button
    METHOD handle_menu_button.
    handle own menubuttons
        IF e_ucomm = 'DETAIL_MENU'.
          CALL METHOD e_object->add_function
                      EXPORTING fcode   = 'ADD1'
                                text    = text1.
          CALL METHOD e_object->add_function
                      EXPORTING fcode   = 'ADD2'
                                text    = text2.
        ENDIF.
      ENDMETHOD.
    The choices  (function codes from your menu) are still handled in the ON_USER_COMMAND.
    Cheers
    Jimbo

Maybe you are looking for