Need Help  in converting LCR to UPDATE when ORA-0001 received during apply

Currently I have streams (one-way) set up between two sites (Site A and B).
Data is inserted at Site A from an application. There is a possibility that the row already exists at Site B with another set of values resulting in Apply getting failed with ORA-0001 error. I have the folllowing DML_HANDLER to update the row at Site B when a row exists in Site B.
++++++++++++++++++++++++
create or replace procedure dept_ora_001 ( in_any sys.anydata)
is
lcr sys.lcr$_row_record;
old_val sys.lcr$_row_list;
new_val sys.lcr$_row_list;
rc pls_integer;
cmd_type varchar2(100);
v_col_deptno sys.anydata;
v_val_deptno number ;
v_col_lastmodified sys.anydata;
v_val_lastmodified date;
v_curr_val_lastmodified date;
pExist number;
begin
rc := in_any.GetObject(lcr);
cmd_type := lcr.get_command_type();
v_col_deptno := lcr.get_value('NEW','DEPTNO');
v_col_lastmodified := lcr.get_value('NEW','LASTMODIFIED');
rc := v_col_deptno.getnumber(v_val_deptno);
rc := v_col_lastmodified.getdate(v_val_lastmodified);
if cmd_type = 'INSERT' then
select count(*) into pExist from scott.dept where deptno = v_val_deptno;
-- Row does not exist.. execute lcr to insert row
if pExist = 0 then
lcr.execute(true);
else
-- Row existis.. compare values of lastmodifed and change the lcr to UPDATE if New DEPT created at source.
select lastmodified into v_curr_val_lastmodified
from nbkl8xk.dept where deptno = v_val_deptno;
if (v_curr_val_lastmodified is null or
v_val_lastmodified > v_curr_val_lastmodified ) then
lcr.set_command_type('UPDATE');
lcr.set_values('OLD',lcr.get_values('NEW'));
lcr.execute(true);
end if;
end if;
end if;
end;
begin
dbms_apply_adm.set_dml_handler
( object_name => 'SCOTT.DEPT',
object_type => 'TABLE',
operation_name => 'INSERT',
error_handler => false,
user_procedure => 'STRMADMIN.DEPT_ORA_001'
end;
++++++++++++++++++++++++++++
The DML handler is getting fired correctly and it is changing the LCR into UPDATE. Now, I am receiving ora-1403 (no data found). This is because the OLD values do not match with the row at Site B. ( I am setting OLD_Values to New_Values in the DML_HANDLER)
To address this I created the following update_conflict_handler.
++++++++++++++++++
declare
v_cols dbms_utility.name_array;
begin
v_cols(1) := 'DEPTNO';
v_cols(2) := 'DNAME';
v_cols(3) := 'LOC';
v_cols(4) := 'LASTMODIFIED';
dbms_apply_adm.set_update_conflict_handler(
object_name => SCOTT.DEPT',
method_name => 'MAXIMUM',
resolution_column => 'LASTMODIFIED',
column_list => v_cols
end;
+++++++++++++++++++++
I am not getting any 1403 errors now. However, the row at Site B is not getting updated with the values at Site A.
Any help is appreciated.
Thanks

I fired the query, am not getting any output from dbms_output.put_line('..|USER_COUNTRY..');
Is that no data is reading or may be any reason else..
in this table store_id is the primary key ..
SQL> set serveroutput on
SQL> CREATE OR REPLACE PROCEDURE test(in_any sys.anydata) IS
2 lcr sys.lcr$_row_record;
3 rc pls_integer;
4 v_type varchar2(20);
5 col_1 sys.anydata;
6 col_2 sys.anydata;
7 lcr_usercountry varchar2(20);
8 lcr_storeid number;
9 TRANS varchar2(20);
10 store_id number;
11 USER_COUNTRY varchar2(20);
12
13 BEGIN
14 rc:=in_any.GetObject(lcr);
15 v_type:=lcr.get_command_type();
16 col_1:=lcr.get_value('NEW','USER_COUNTRY');
17 rc:=col_1.GetVarchar2(lcr_usercountry);
18 col_2:=lcr.get_value('NEW','STORE_ID');
19 rc:=col_2.getnumber(lcr_storeid);
20 select user_country into user_country from dev03.testrep1 where user_country=lcr_usercountry and store_id=lcr_storeid;
21 dbms_output.put_line('---------||USER_COUNTRY ||-----------');
22 END;
23 /
Procedure created.
Thanks for your help ....

Similar Messages

  • Hello, i really need help. I had just updated my iphone 3gs to 6.0.1, and after I updated, it won't activate.

    Hello, i really need help. I had just updated my iphone 3gs to i.o.s. 6.0.1, and after I updated, it won't activate.I tried it in itunes and it always says " We cannot activate your iphone at this time..." and when I activate using Wi-Fi, it says, "Your iPhone cannot be activated because the activation server is temporarily unavailable." I could swear that my Wi-Fi is fine, and my Itunes is on the latest version.  Is this a bad thing or does this normally occurs? Can I still fix this ? I'm so desperate to use my iphone cause I use it everyday for personal purposes. I sure would appreciate any tip or help . PLSSSS ! Thank you for that wonderful being that can help.

    Do not take it to a third party repair shop - downgrading causes problems and voids your warranty.
    I had to unlock it so that i could really use it as a phone.
    And that is the root of the problem. Unless you had your carrier unlock it, it was hacked and cannot be legitimately activated. Even if you don't care about warranty or problems, downgrading simply will not help an activation issue.

  • I need help with resetting my ichat. When i try to login now it wont let me... it says "AOL Instant Messenger password" and then "iChat can't log in to ... because your login ID or password is incorrect. How do I reset this if I cant log in?

    I need help with resetting my ichat. When i try to login now it wont let me... it says "AOL Instant Messenger password" and then "iChat can't log in to ... because your login ID or password is incorrect. How do I reset this if I cant log in? When I try to press online the same thing pops up and I have no way of logging in or asking for help.

    Hi,
    iChat (it would help to know which version) can accept Apple IDs as valid AIM Screen Names.
    However if you have iChat 5 or earlier you cannot use ones ending in @me.com or @icloud.com issued by iCloud. (they can be used in iChat 6 or Messages as these versions make a double login to AIM and Apple to allow the use of the password).
    In addition if you are using an Apple ID for an AIM Screen Name the password still needs to keep to the 16 character limit that AIM has.
    AN @mac.com name can be used on any version of iChat  (Until the 30th June 2014)
    As it does not need a double check with Apple you can use it to log in to the AIM Web pages
    Login here with an AIM Name registered at AIM or and @mac.com name and see if you get any suspended account messages.
    Sometimes account can be suspended. Usually because something has triggered the "Unusual Activity" item.
    About a year ago many @mac.com users that travelled out of their own country found themselves suspended when they got home.
    If the Name checks out of if an Apple ID the password in known to be 16 characters or Less then do this:-
    In Lion upwards open a Finder Window and use the Go Menu whilst holding down the ALT key.
    Select the Library that appears in the menu list.
    Navigate to Preferences.
    (If you have version earlier than Lion the just navigate to ~/Library/Preferences (that's the Library in you Home - Little House icon - folder)
    Fnd com.apple.ichat.aim.plist (even if you are using Messages)
    Drag the file to the Trash and Restart the app.
    7:39 pm      Thursday; May 29, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • I need help in converting a pdf to a fillable form in my adobe

    I need help in converting a pdf to a fillable form in my adobe

    "Adobe" is a company. If you mean "Adobe Reader" then you can't (at least not easily). You need Adobe Acrobat for that.

  • Need help in converting numbers to Italian text

    Need help in converting numbers to text in Italian language. I want to knw is there any method other than SE63 to translate these text in one shot. I have tried with LSMW also (as the sheet is in XLS format ).Plz reply if anyone is aware of this ..

    hi,
    chk this code.
    CALL FUNCTION 'SPELL_AMOUNT'
    EXPORTING
    amount = amount
    currency = 'EUR'
    filler = ' '
    language = 'E'  => give the language as italian
    IMPORTING
    in_words = amountrs.
    rgds
    anver
    pls mark all hlpful answers

  • Need help in converting date format

    Hi,
    Need help in converting date format from 'DD-MON-YYYY' to 'YYYY-MM-DD' in an .rtf template as I believe xml publisher supports the date format as 'YYYY-MM-DD' only.
    Thanks,
    Raj.

    I got the same problem, anyone know how to solve this problem? I allready found some date functions on http://blogs.oracle.com/xmlpublisher/2008/09/date_functions.html . I also tried <?xdoxslt:month_name(xdoxslt:get_month(xdofx:substr(NEED_BY_DATE, 4,3)), $_XDOLOCALE), 0, 'nl-NL')?>, but then it returns a namespace error (Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'xdofx' used but not declared.). Anyone know how to fix this?
    Edited by: user11165753 on 7-dec-2009 23:50

  • I need help in finding a free update for my windows 7.5 mobile

    I need help in finding a free update for my mobile 7.5 windows phone
    Message was edited by: chevycamer427

    http://www.windowsphone.com/en-us/store/app/adobe-reader/bc4f319a-9a9a-df11-a490-00237de2d b9e
    [topic moved to Windows Phone subforum]

  • I have an error -5000 when I try to record in GarageBand..I urgen need help, I have an error -5000 when I try to record in GarageBand..I urgen need help

    I have an error -5000 when I try to record in GarageBand V10,02..I urgen need help, I have an error -5000 when I try to record in GarageBand..
    I just reinstal OSX 10,9,2 marveiks and downdload the GB.. but when I try to record, the error ocurr
    I urgen need help
    thanks

    This is probably one of the files that is required by the template you are using.
    These files are inside the iWeb app. Control click the iWeb app icon and select "Show package contents".
    You need to dig down through the folders and files to find what you want...
    Contents/Resources/da.lproj/Templates/
    If the file is missing you would need to re install the iWeb app...
    http://www.iwebformusicians.com/iWeb/iWeb-Tips.html

  • Hello everyone I need help! Why i cant Update to Mountain Lion if Im gonna try to update my Macbook Pro with Mac OS X 2.3 GHz Intel Core i5. It always says "Your Software is up to date" which is only Mac Os X ver. 10.7.5

    Hello everyone I need help! Why i cant Update to Mountain Lion if Im gonna try to update my Macbook Pro with Mac OS X 2.3 GHz Intel Core i5. It always says "Your Software is up to date" which is only Mac Os X ver. 10.7.5

    Not sure what exactly you did (or not), but it looks as if you should attempt doing it all again, only this time all right and by the book. Many millions have done so, and sure it'll work for you as well.
    If you've indeed purchased ML already, you'll find it exactly there in the App Store: under Purchases.

  • I need help..after I've updated my iMac to the efi 1.3.. After rebooting it won't start at all.. Instead it's giving this beeping sounds..repeatedly..

    I need help..after I've updated my iMac to the efi 1.3.. After rebooting it won't start at all.. Instead it's giving this beeping sounds..repeatedly..

    http://support.apple.com/kb/HT2341

  • I need help with my Nokia 5800 update to v40.0.005

    Hey im having trouble with updating my Nokia 5800 to v40.0.005.
    The version on my phone at the moment is v21.0.025 and when i try to update it on my phone it says no update available.
    I tried downloading Nokia Update Software and getting it from there but the program wouldnt work either.
    Is there any other way i can get the v40.0.005 were it should work? or even getting the knetic scrolling and applications without needing to get v40.0.005?
    Please need help!
    Thanks
    Solved!
    Go to Solution.

    Under your battery, there's a product code on a sticker (X: 0586707). Go here: http://europe.nokia.com/support/download-software/device-software-update/can-i-update and type in your productcode to see if there should be an update for your productcode. If there's not, you could take your phone to a Nokia Carepoint and ask if they could do it - no promises. Or else you have to wait untill your productcode gets it.

  • I need help to convert hours,minutes and seconds to seconds.

    Hi, I need help with the code on how to convert the hours,minutes and seconds to seconds. I don't know which formula to use so that I can get the results in total number of seconds. Thanks.

    Jos ("when in doubt: parenthesize correctly")Bracist.You're more right than you'd known: last week I climbed over a safety
    fence (which I wasn't supposed to do of course) to adjust the position
    of an optical measurement device we installed in a huge production
    machine in a factory. I stepped on some sort of hose; the end of that
    hose broke loose and hit me straight in the middle of my lower jaw. My
    front teeth feel wiggly now and my molars on the left of my lower jaw are
    not what they used to be. This Wednesday I get that all fixed at some
    dental clinic. Keep your fingers crossed because me+dentists == war.
    My tongue continuously keeps on reporting craters and disaster ;-)
    Jos, how's it going? Besides a possible loss of some teeth, I'm fine ;-)
    My Spring/Hibernate journey continues. I'm trying out Hibernate 3.2
    annotations and the Ant tools. So far, so good.Good to hear. At the moment I'm putting my teeth (sic) in that darn snmp
    stuff which simply refuses to work the way I want it and besides that I'm
    heavily involved in some of that SAP stuff. Spring is not in the vicinity for
    me in the next couple of months sadly enough.
    kind regards,
    Jos

  • Need help to convert SQL MSSQL statement to work with PL in ORACLE

    Hi All,
    I have the trigger below and it worked on MSSQL server for windown and
    I really need your help to convert this trigger to work on PL/ORACLE:
    create trigger deleteLD
         on tablea for delete
    as
    set nocount on
    begin
         declare @tablename varchar(100)
         declare @dropSql varchar(50)
         select @tablename= dataset from deleted
         set @tablename = 'LD_' + @tablename
         set @tablename = @tablename + 'UTMSTATS'
         if exists (select * from sysobjects where name = @tablename)
         begin
              set @tablename = 'drop table ' + @tablename
              EXEC (@tablename)
         end
    end
    GO
    Your help is greatly appreciated.
    Thanks,
    JP

    not sure if this is something that you want:
    Create Or Replace Trigger deleteLD
      Before Delete on tablea
    Declare
      vCtr          number := 0;
    Begin
    select count(*)
       into vCtr
       from all_tables
      where table_name = :new.tablename;
    if vCtr > 0 then
       dbms_utility.exec_ddl_statement('drop table '||:new.table_name);
    end if;
    End;note: not tested

  • Need help Firmware 6.0.2 updated yesterday draining

    Need help updated Firmware to 6.0.2 crazy mad battery draining. This phone even switch to airplane mode the last three hours still drained about 30% battery life what is going on apple please sort this problem out.

    Mines drains over 40% in two hours this is terrible I hardly even use it at all.

  • I need help to convert photos in the .swf format to a format that will open on iOS

    I need help converting photos in the .swf format to a format that will work on my Mac.  Thanks

    SWF is a Flash file that should be able to be opened with your web browser on your Mac. Probably not on iOS though.
    You will likely need to find the source file for the application that created the SWF and the image will be in that. You could then export/extract the image and have it as a stand alone file.
    It does look like there are applications that can do what you are looking for though: https://www.google.com/search?q=SWF+to+JPG

Maybe you are looking for

  • Two Apple ID's and the cloud future

    I am hoping that someone can help me understand what the future will hold for my "Apple ID" situation.  I still use my original Apple ID that was set up in the early days to purchase music through the iTunes store.  This is still my AppStore ID, iTun

  • I have a 8gb ipod i have used 5.5 gb but i only have 982 available  ???

    how does this happen i m not very good with techolgy help?

  • Convert to PDF and Email crashes

    Hi, Encountered this problem when I right click on a word file and select "Convert to PDF and Email". It will always crashes with the error "Adobe Elements had stopped working" and the message indicating something to do with ADIST.DLL. Had tried the

  • Opening Final Cut Studio 3 Projects on Mac Pro (Snow Leopard) & MacBook Pro (Lion)

    Hi Everyone, Right i've been trawling the forums in regards to Lion's compatibility with Final Cut Studio 3. There seemed to be a mixed bag of reports, some running FCP fine on Lion, others having issues. For this reason alone I decided to keep my ma

  • Creating DOM Document with elements

    I want to recreate a new document, I am wondering if there is a way to create one using only elements, so I dont have to go through the whole document and appendchild(), or if there are any other ways of doing this.