Delete allowed in a multirow blk only if no records exist in another table

How can I delete an existing row in a multirow block after checking that no records exist in another table ?
How do I proceed please ?
I know I need to check the primary keys of both tables to do that . Please help.

I've written the following code in the KEY-DELREC trigger :
DECLARE
*     Fail EXCEPTION;*
*     alert_title varchar2(100) := null;*
*     p_button_choice number := 0; -- 10g : for Stop_Alert, Caution_Alert & Note_Alert*
*     cnt NUMBER;*
*     choice NUMBER;*
Begin
*     If :system.record_status NOT IN ('INSERT', 'NEW') THEN -- can be CHANGED or QUERY mode*
*          begin*
*          SELECT count(AMD_CODE)*
*          INTO cnt*
*          FROM t_mmamd,t_amdtype*
*          WHERE AMD_CODE = :AMD_CODE*
*          AND MMA_AMD_CODE = AMD_CODE;*
*     IF cnt > 0 THEN*
Alerts.Stop_Alert('Error: IMDG Code '||:AMD_CODE||'Delete not allowed!!Exists in t_mmamd table', choice);
RAISE FORM_TRIGGER_FAILURE;                       
*          ELSE*
*          alert_title := 'Are you sure to remove this record ?';*
*          Alerts.Stop_Alert_YesNo (alert_title, p_button_choice);*
If p_button_choice = 1 Then
*     delete_record;*
End if;
END IF;
end;
Else -- record status is in INSERT or NEW mode
*          delete_record;*
*     End if;*
End;
It works okay and prevents me from deleting records in the other table . However I get the following errors when I try to delete a record which doesn't exist in t_mmamd table :
Could not resolve record(2 tries) keep trying?
Error : 40501 - oracle Error unable to reserve record for update or delete .

Similar Messages

  • Pickup only the newest record in an Internal Table.

    Hi all:
    I have and internal table that i am accesing in a transformation.
    Which is the best approach to read from the internal table only the
    record with the newest date. Data look like this:
    Date_________MAT___ Qty
    12.08.2009___4050___70
    10.05.2009___4050___30
    18.11.2009___4050___42
    20.07.2009___4050___28
    In this case, for Material 4050 i need only the third record (18.11.2009),
    any code example or guideline..?
    Regards,

    Hi,
    You can sort the internal table by date and material in descending order and then perform read on the internal table with key as material. this would bring the latest date for that material.
    Regards,
    Rk.

  • Getting only the newest records in a Grandchild table

    Hi
    I have created a new table in the Siebel schema on an Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    This table is called CX_ASSET_XM and is a Grandchild table of S_ASSET
    CX_ASSET_XM has a parent table S_ASSET_X
    So the structure is like so
    S_ASSET  x 1 record
    S_ASSET_X x 2 child records
    CX_ASSET_XM x 1 grand child records
    Therefore the cardinality is one Grandparent can have 2 Grandchild records
    This CX_ASSET_XM table will hold information about TCP/IP calls of a Grandchild asset. These calls are not synchronized. therefore one Grandchild asset may make a call today but the other one has not made a call since yesterday.
    In my query I find all the grand children records that have been created today (sysdate) and then traverse up the relationship to find the Grandparent, then I traverse back down to find the other twin in the Grandchildren tuple.
    The problem with my query is that it returns every single TCP/IP call a pair has made but I only want the most recent callback of each grandchild to analyse
    SELECT (cb.SSID), cb.created_by, cb.callback_date, cb.callback_num, asset.desc_text, asset.prom_integ_id, asset.integration_id
    --Traversing Up to find the Grandparent record of the
    FROM SIEBEL.CX_ASSET_XM cb
        JOIN SIEBEL.S_ASSET_X assetx
          ON cb.SSID = assetx.attrib_37
        JOIN SIEBEL.S_ASSET asset
          ON assetx.par_row_id = asset.row_id
    WHERE asset.prom_integ_id IN
    --Traversing Down to find the other twin in the pair
    (   SELECT asset.prom_integ_id
        FROM SIEBEL.CX_ASSET_XM cb
        JOIN SIEBEL.S_ASSET_X assetx
          ON cb.ssid = assetx.attrib_37
        JOIN SIEBEL.S_ASSET asset
          ON assetx.par_row_id = asset.row_id
    ORDER BY cb.callback_date DESC;
    e.g. if there are 80 grandchildren which have made two TCP/IP calls that would make a total of 160 records, which is what the query above returns.
    However I want 80 records to be returned
    e
    Grandchildren
    Callback Date
    1111AAAA (Pair 1)
    10-OCT-13
    1111AAAB (Pair 1)
    09-OCT-13
    2222AAAA (Pair 2)
    10-OCT-13
    2222AAAB (Pair 2)
    07-OCT-13
    As you can see from the table, atleast one of the pair will have a Callback_Date = Sysdate (Today) which is how I will need to find them in the table before traversing up.
    How do I achieve these results. I have tried GROUP BY, DISTINCT, ROWNUM = 1

    Hi,
    968432 wrote:
    Sorry for my ignorance but how do I incorporate the ROW_NUM function into my query, or will it be a new query from scratch.
    When you say partition, does that mean the partition would be between my traversal up the tables to the grand parent and then back down again?
    You can use ROW_NUMBER with something very much like your existing query; there's no need to start from scratch; you just won't repeat the joins in the WHERE clause.  You'll just be joining the tables once.  If it really helps you to think of traversing either up or down, then go ahead, but you mind find it simpler just to think of joining.  Every row of the join will include some expression(s) that uniquely identifies the grandparent; that's what you'll PARTITION BY.
    It would be a lot easier to explain and to understand if we had some sample data and desired results.  Either post CREATE TABLE and INSERT statements for a little sample data, or phrase the question in terms of tables that anybody with Oracle probably has, such as those in the hr schema.  (People in hr.employees are related to deparatments in hr_departments, and departments are related to places in hr.locations, so location is the grandparent of employee.  If you knew how to find the most recently hired employee from each location in the hr schema, then you'd know how to solve your problem in your schema.  For example, if you wanted these results:
    CITY                 DEPARTMENT_ID EMPLOYEE_ID LAST_NAME  HIRE_DATE
    London                          40         203 Mavris     07-Jun-2002
    Munich                          70         204 Baer       07-Jun-2002
    Oxford                          80         167 Banda      21-Apr-2008
    Seattle                        100         113 Popp       07-Dec-2007
    South San Francisco             50         128 Markle     08-Mar-2008
    Southlake                       60         104 Ernst      21-May-2007
    Toronto                         20         202 Fay        17-Aug-2005
    you could get them like this:
    WITH  got_r_num  AS
        SELECT  l.city
        ,       d.department_id
        ,       e.employee_id, e.last_name, e.hire_date
        ,       ROW_NUMBER () OVER ( PARTITION BY  l.city
                                     ORDER BY      e.hire_date  DESC
                                   )   AS r_num
        FROM    hr.employees    e
        JOIN    hr.departments  d  ON   d.department_id  = e.department_id
        JOIN    hr.locations    l  ON   l.location_id    = d.location_id
    SELECT  city
    ,       department_id
    ,       employee_id, last_name, hire_date
    FROM    got_r_num
    WHERE   r_num = 1

  • Delete Allowed generation for tables

    At my group level I have set a value for the "Delete Allowed EL expression". In table layout though, it uses this value to set the rendered property of the checkbox rather than the column, meaning the users still see a column called "Delete ?" with just nothing in it. I've created a custom template and moved the rendered attribute from the selectBooleanCheckbox up to the column.
    Of course I may be doing something wrong here or this might cause problems elsewhere but in case neither of those hold true I thought I would mention it as a possible future enhancement ?
    Cheers,
    Brent

    Brent,
    That's fine, the reason we only hide the checkbox is that it allows for row-specific delete rules. You can conditonally render the delete checkbox based on some attribute values of the row.
    Steven Davelaar,
    JHeadstart Team.

  • Delete Allowed EL Expression

    Hi
    I am trying to restrict users from updating and deleting rows based on certain conditions.
    I have put the following into the Update Allowed and Delete Allowed
    #{data.StudentsPageDef.StudentsCustomerStatus.inputValue=='ACTIVE'}
    When I look at the generated page the Read Only for the columns is set to
    #{!(data.StudentsPageDef.StudentsCustomerStatus.inputValue=='ACTIVE')}
    So this is all good as it sets it to read only if the student is not active.
    However the delete checkbox has no restrictions and I can therefore delete records. The update is restricted so I know the EL expression is fine but it seems to ignore the delete.
    Thanks
    Rich

    Also, just to note that if I go in and edit the page manually I can set the disabled property of the delete checkbox and it works fine.
    For some reason, JHeadstart doesn't seem to generate it though???

  • How do I delete my old Apple ID that only appears when I try to update my apps...my new I'd works fine with everything else

    How do i delete an delete delete an old Apple ID that only appears when I try to update my apps..a

    All of the purchase you made on the old AppleID are permanently connected to that AppleID. The only way you can get rid of it is to repurchase everything again with the new AppleID.

  • Can I do a duplicate search to delete on my ipod classic 120gb only?  There are no duplicates on my itunes... I think these duplicates arose when I did a restore, and had to reload from the cloud, and my computer backup.... please help...

    I have an ipod classic 120gb...
    Somehow I have managed to get mutiple duplicates.....
    I had a computer crash... and I restore several songs from the cloud, and from my computer backup from an external drive...
    and also, from past purchases on itunes...... some songs I had loaded from my own cd collection....and songs had overlapped......
    I knew I had duplicates before the crash and never took care of it.... but now of course there are more...
    I have taken care of the duplicates in itunes, by deleting them one by one..... I made the mistake of checking boxes then highlighting and doing a mass delete... thinking it would only delete my check boxes.... and loss a lot of music... so had to restore backups again....
    so.......
    Ipod......... how do I delete duplicates from the ipod, without loosing music from my ipod... I have lost music that is still there I believe on the Ipod that is not on my itunes... but I am not sure...and I can not find a search duplicates in itunes for Ipod....  can anyone help me on this... is there a way to do it, without going through 8 days of music line by line??
    Thank you

    Restore the iPod and reload it from the library... Ah, but there might be media on the device that isn't in the library yes?
    See Recover your iTunes library from your iPod or iOS device and a script called DeDuper which can help remove unwanted duplicates from iTunes if you end up needing to do a blanket recovery from the iPod. See this  thread for background on DeDuper.
    tt2

  • Sync session failed to start on my ipod touch. tried to delete back up history but it only shows my daughters ipod touch and not mine! Im unable to update or purchase new aps, not sure how to fix this problem?

    sync session has failed to start on my ipod touch. Tried to delete the back up but it only shows my daughters ipod touch. Iam unable to update or purchase new aps, not sure how to fix this problem?

    Try:
    https://discussions.apple.com/thread/3415227?start=0&tstart=0
    https://discussions.apple.com/message/16400530#16400530

  • Delete Allowed Property For Current Record

    I have a requirement where I need to make a record allowed proeprty delete_allowed as false.
    Eg:
    If :variable:='YES' then
    SET_ITEM_INSTANCE_PROPERTY('block_name.item',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_FALSE);
    end if;
    I cannot set delete_allowed property here, so how can I set delete allowed property to false?
    if I use
    SET_ITEM_PROPERTY('block_name.item',ENABLED,PROPERTY_FALSE);
    it will set property for all the records in the block, I have a multi-record block
    I am using Oracle Forms 10g
    Thanks

    Thanks for the reply.
    Yes I was thinking of doing this.
    if I put a validation in key-delrec trigger, then do I need to explicitly call a commit or any other method to delete a record if condition is not true?
    Eg:
    If :variable:='YES' then
    Message(' DELETE IS NOT ALLOWED');
    Raise Form_Trigger_Failure;
    ELSE
    commit or delete_record;
    End if;

  • Each time I try to start iTunes after it was closed, it wouldn't start. I have to go to the Task Manager delete Apple Push from processes and only after that iTunes statrs again. What is wrong?

    Each time I try to start iTunes after it was closed, it wouldn’t start. I have to go to the Task Manager delete Apple Push from processes and only after that iTunes statrs again. What is wrong

    Did you manage to get it working mine disappeared after I while I managed to download it but now my laptop/iTunes won't recognise my iPhone!

  • You are not allowed to have zero line only  massages no. m8278

    Hi all,
    At the time of MIRO Reversal we are facing error massage.
    You are not allowed to have zero line only  massages no. m8278
    Because of wrongly 0.00 amount posted in MIRO posting.
    What we do please help me it is production system error.
    Thanks & Regards,
    Juhi
    Edited by: juhis022 on Nov 8, 2011 1:43 PM

    this is because for the document which you posting MRIS is not covered with invoicing plan settlement.
    Please create a invoicing plan and settle through MRIS.

  • Problem in block property (delete allowed)

    hi friends,
    i have created a form having two blocks with non-isolated relation in them. i have set the delete allowed property to true for child block and false for master block. But when i run the form it will not allow me to delet the record from the child block as the delete allowed button appears in disabled form in the toolbar...
    please help in enabling the button so that i can delete the record at runtime for the child block

    which kind of toolbar did you use. selfwritten or oracle-standard ?

  • Are there any apps which will allow local calling using data only that do not require any special numbers called out initially and does not require the receiver to have a similar app or account?

    Are there any apps which will allow local calling using data only (not minutes, no extra charge) that do not require any special numbers called out initially and does not require the receiver to have a similar app or account?  Just for random local calling.

    Yup.
    Here is a way you could solve this by adding an extra column and a small lookup table:
    The lookup table is here for the copying:
    0
    1
    k
    kilo
    2
    M
    mega
    3
    G
    giga
    4
    T
    tera
    5
    P
    peta
    6
    E
    exa
    7
    Z
    zetta
    8
    Y
    yotta
    In table 8 (the one on the left in the image) column A is where the values are. 
    B1=A1÷(1024^VLOOKUP(INT(LOG(A1, 1024)), Binary Prefixes::A:D, 1))&" "&VLOOKUP(INT(LOG(A1, 1024)), Binary Prefixes::A:D, 2)&"B"
    this is shorthand for... select cell B1, then type (or copy and paste from here) the formula:
    =A1÷(1024^VLOOKUP(INT(LOG(A1, 1024)), Binary Prefixes::A:D, 1))&" "&VLOOKUP(INT(LOG(A1, 1024)), Binary Prefixes::A:D, 2)&"B"
    select cell B1, copy,
    now select all the cells in column B, paste

  • My messages are linked somehow between my phone and iPad. I need to make space on my iPad so I want to delete the messages off my iPad only. If I delete my messages off of my iPad, will they also be deleted off of my iPhone?

    My messages are linked somehow between my phone and iPad. I need to make space on my iPad so I want to delete the messages off my iPad only. If I delete my messages off of my iPad, will they also be deleted off of my iPhone?

    Welcome to the Apple community.
    If you delete messages on one device they arent deleted on others.

  • Feature request: Allow direct connections for contacts only

    Hello, on Windows there is an option "Allow direct connections to contacts only" as described on http://en.kioskea.net/faq/32357-skype-hide-your-ip-from-people-who-are-not-on-your-contact-list. Many people including myself would like to see this feature implemented in the Linux client. There are solutions to protect the IP from resolvers like setting up proxies. However, the performance of free SOCKS-proxies is mostly very bad. VPNs with an appropriate bandwidth also cost an amount of money and additionally, it is difficult to only route Skype traffic through a VPN. Setting up a VM with Windows or WINE just to run Skype is an overkill as well. I consider it inconvenient that this feature is implemented on Windows while - in my opinion - mainly Linux users being aware of security might be in need for this feature. Therefore, I request to implement such a functionality into the Linux client. Kind regards from Germany

    If  you want to enable that feature on a Skype client that does not offer it in the GUI you would have to do it manually.  You can follow the guidance here and the same information applies to the Linux client and any other client you have root or file-level access to. http://community.skype.com/t5/Modern-Windows-from-Windows/Windows-8-IP-Hiding/m-p/2876437/highlight/true#M19476 Linux path:/home/Username/.Skype/YourSkypeName/config.xml

Maybe you are looking for