To delete child records manually without using oracle's delete cascade

Hi all
I have to write a procedure that accepts schema name, table name and column value as parameters....I knew that i need to use metadata to do that deleting manually....I am a beginner...can somebody help me with the procedure?

Hi Guru,
They told me to use this procedure...but this procedure isn't working...can you help me to understand this procedure?
CREATEOR REPLACE PROCEDURE delete_cascade(
    table_owner          VARCHAR2,
    parent_table         VARCHAR2,
    where_clause         VARCHAR2
)IS
    /*   Example call:  execute delete_cascade('MY_SCHEMA', 'MY_MASTER', 'where ID=1'); */
    child_cons     VARCHAR2(30);
    parent_cons    VARCHAR2(30);
    child_table    VARCHAR2(30);
    child_cols     VARCHAR(500);
    parent_cols    VARCHAR(500);
    delete_command VARCHAR(10000);
    new_where_clause VARCHAR2(10000);
    /* gets the foreign key constraints on other tables which depend on columns in parent_table */
    CURSOR cons_cursor IS
        SELECT owner, constraint_name, r_constraint_name, table_name, delete_rule
          FROM all_constraints
         WHERE constraint_type ='R'
           AND delete_rule ='NO ACTION'
           AND r_constraint_name IN(SELECT constraint_name
                                       FROM all_constraints
                                      WHERE constraint_type IN('P','U')
                                        AND table_name = parent_table
                                        AND owner = table_owner)
           ANDNOT table_name = parent_table;-- ignore self-referencing constraints
    /* for the current constraint, gets the child columns and corresponding parent columns */
    CURSOR columns_cursor IS
        SELECT cc1.column_name AS child_col, cc2.column_name AS parent_col
          FROM all_cons_columns cc1, all_cons_columns cc2
         WHERE cc1.constraint_name = child_cons
           AND cc1.table_name = child_table
           AND cc2.constraint_name = parent_cons
           AND cc1.position = cc2.position
        ORDERBY cc1.position;
BEGIN
    /* loops through all the constraints which refer back to parent_table */
    FOR cons IN cons_cursor LOOP
        child_cons   := cons.constraint_name;
        parent_cons  := cons.r_constraint_name;
        child_table  := cons.table_name;
        child_cols   :='';
        parent_cols  :='';
        /* loops through the child/parent column pairs, building the column lists of the DELETE statement */
        FOR cols IN columns_cursor LOOP
            IF child_cols ISNULLTHEN
                child_cols  := cols.child_col;
            ELSE
                child_cols  := child_cols ||', '|| cols.child_col;
            ENDIF;
            IF parent_cols ISNULLTHEN
                parent_cols  := cols.parent_col;
            ELSE
                parent_cols  := parent_cols ||', '|| cols.parent_col;
            ENDIF;
        END LOOP;
        /* construct the WHERE clause of the delete statement, including a subquery to get the related parent rows */
        new_where_clause  :=
            'where ('|| child_cols ||') in (select '|| parent_cols ||' from '|| table_owner ||'.'|| parent_table ||
            ' '|| where_clause ||')';
        delete_cascade(cons.owner, child_table, new_where_clause);
    END LOOP;
    /* construct the delete statement for the current table */
    delete_command  :='delete from '|| table_owner ||'.'|| parent_table ||' '|| where_clause;
    -- this just prints the delete command
    DBMS_OUTPUT.put_line(delete_command ||';');
        EXECUTE IMMEDIATE delete_command;
    -- remember to issue a COMMIT (not included here, for safety)
END;Edited by: BluShadow on 09-Oct-2012 16:05
added {noformat}{noformat} tags for readability.  Please read: {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Steps to Upgrade PT8.49 to 8.50 Manually without using an Upgrade Template

    Folks,
    Hello. I am Upgrading PeopleTools 8.49 to 8.50 Manually without using an Upgrade Template because I cannot download an Upgrade Template from Oracle.
    Upgrading is actually add/drop some tables/views in PeopleTools 8.49 Database using Chang Assistant 8.50.
    According to the document "Enterprise PeopleTools 8.50 Upgrade" Chapter 3 and Chapter 4, after configure Change Assistant 8.50 and EMF, we need to creat an Upgrade job and run some scripts.
    I have configured Change Assistant 8.50 and EMF. EMF run successfully. After that, I don't know the exact steps to do in Change Assistant.
    Can any folks tell me the steps to upgrade PT8.49 to 8.50 manually in Chang Assistant without using an Upgrade Template after configure Change Assistant and EMF ?
    Thanks.

    Do you know what is Change Assistant ? It is running job defined from template and indicate when step has to be done manually. But Change Assistant itself is nothing but an assistant, it does not build record, it does not run DMS, it does not run sql script, for all those Change Assistant is calling corresponding tools (AppDesigner, DataMover, SQL*Plus). Consequently, if you don't have template, you should do yourself every single step usually ran by the PsCA, but you won't need PsCA itself, just run manually whatever indicated in the doc (basically replace "PsCA" by "manually").
    As I already told you earlier, it is tedious, but works fine if you pay attention enough.
    HTH,
    Nicolas.

  • How to create inspection lot manually without using QA01 Transaction code?

    Hi,
    Please anybody give procedure for creating Inspection Lot Manually without using Transaction Code QA01

    Hello, Srinivas,
    If you want another T code only then you can try QA01A.
    or you can create a Physical Sample with QPR1 and then click on the button there to create inspection lot. To create inspection lot for that Physical sample (you will able to see that button only after releasing the sample) Or you can use QPR5.
    But let me know the reason why you want T code other than QA01.
    Regards,
    Shyamal

  • How to create logical standby database without using Oracle Grid Control

    Hi All,
    I want to create Logical standby database on 11gr2 on RHEL 5 without using oracle Grid Control.
    I already have a primary database as well as physical standby database.
    What i want to create a logical standby database as well on the same machine where physical standby database is running.
    So anyone of you help me out to do that
    Thanks in advance

    Hi,
    Creating a Logical Standby Database
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ls.htm#SBYDB00300
    Regards,
    Tom

  • Delete child record

    hi is there a quikestt way i can delete child record of the parent table,lets say i have 100 record in child record related to one parent how can i delete the 100 record in smart way not by deleting one by one vale

    You coluld find it easily by googling..
    create table test_dept(dept_id number primary key,dep_name varchar2(50));
    create table test_emp(emp_id number primary key,
          dept_id number references test_dept on delete cascade,emp_name varchar2(50));

  • How to connect from java without using oracle client installation

    hi ,
    Please tell me how to connect from java without using oracle client
    Thanks & Regars

    http://www.orafaq.com/wiki/JDBC#Thin_driver

  • Deleting Child records which are not associated to any parent

    Hi
    We have seen that in the application though the Activty records has been deleted the child records like sample dropped and the roduct details has remained in the system. This happened cos in R18 when contact was deleted activty got deleted but the Activity child records remained in the application.
    we found that child records are present by looking into record utilization.
    Wanted to know if there is any way to delete these child records from teh application cos we are unable to query for them from UI as well as via webservices.
    any pointers would be helpful.
    -MR

    There is not a reporting subject area or folder available on Books. The workaround we employed was to create a field on the entity that was assigned books and that field was checked when the books were assigned. We are using web services to assign books and the web services also updates the field "Books Assigned". This gives us a way of reporting on that field to see those records without book assigned.

  • Deleting Child Records

    I'm a bit confused on how to accomplish the deletion of child records in a master/detail relationship.
    I have a master table and a child table. I created a foreign link between the tables. On my detail table, I have a Delete button, which I would like to use for removing child records. I understand for the master table, I will need to enable cascade delete to remove the master and all children records.
    Whenever I try to delete a child record I get the following error, integrity constraint - violated child record found. I understand the error, but how can I remove a single child record without deleting the master record. For example, I may have a 1 master record and 20 child records. I only want to remove one of the child records. The deletion seems to work fine when using AppModule or SQL Developer. Thanks.

    Thanks Surendrams. Your question made me take another closer look. Apparently, I was calling the Delete operation from the master table. I added another Delete operation in the Bindings from my child table and the deletion is now working. I should have caught this the first time. Thanks.

  • Delete internal table rows without using loop statement

    i have an internal table which consists of 100 records.
    i need to keep only first 5 records.
    without using the loop statement i need to delete the rest of the records. how can we achieve this result.
    i.e.  delete itab1 where  "recordno"  > 5.
    regards.
    ZG

    Hi,
    Delete itab [FROM idx1] [TO idx2] {Where (log_exp)]
    To delete several lines at once, you have to specify at least one of the additions FROM, TO, or WHERE. You can only use the additions FROM and TO with standard tables and sorted tables.
    Delete itab [FROM idx1]
    If you specify FROM, all the table rows from the table index idx1 onwards are included.
    Delete itab [TO idx2]
    If you specify TO, all the table rows from the table index idx2 onwards are included.
    PARAMETERS: p_carrid TYPE sflight-carrid,
                p_connid TYPE sflight-connid.
    DATA: BEGIN OF seats,
            fldate    TYPE sflight-fldate,
            seatsocc  TYPE sflight-seatsocc,
            seatsmax  TYPE sflight-seatsmax,
            seatsfree TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE STANDARD TABLE OF seats.
    SELECT fldate seatsocc seatsmax
           FROM sflight
           INTO TABLE seats_tab
           WHERE carrid = p_carrid AND
                 connid = p_connid.
    LOOP AT seats_tab INTO seats.
      seats-seatsfree = seats-seatsmax - seats-seatsocc.
      MODIFY seats_tab INDEX sy-tabix FROM seats.
    ENDLOOP.
    ENDLOOP.
    SORT seats_tab BY seatsfree DESCENDING.
    DELETE seats_tab FROM 5.
    Thanks & Regards,
    ShreeMohan
    Edited by: ShreeMohan Pugalia on Jul 21, 2009 4:28 PM

  • Create foreign keys to delete child records

    I am unfamiliar with foreign keys, I have 3 tables one is the parent table if a record is deleted in the parent table I would like the record to be deleted from the child record but I think that I am also confused about which should be the parent table
    (purpose is to use in a form)
    parent table (i think)
    AdminEntry table
    entryid ,
    date1,
    date1desc,
    date2,
    date2desc,
    date3,
    date3desc
    In a form each date and its description is placed in the following table
    CalendarEntry table
    calendarid,
    date,
    datedesc
    entryid (fk)?
    so CalendarEntry will have many entries at least 3 from one entryId, this I get but what if I want to delete lets say date2 and date2desc record. If I delete it from AdminEntry table how will calendarEntry table know which one to delete?
    Please help very confused.
    (the other table also inserts to the CalendarEntry table)

    There is a demo of this functionality in Morgan's Library at www.psoug.org under Foreign Keys.
    Look for ON DELETE CASCADE.

  • Delete entire database i m using oracle 11g enterprise version

    Hi,
    I want to delete entire database from my laptop, actually I have installed 3 databases Oracle11g, I want to delete all of them . I have deleted it from registry but also its not totally deleted from my system.

    Hello,
    I want to delete entire database from my laptop, actually I have installed 3 databases Oracle11g, I want to delete all of themIn fact there are 2 things, the Databases and the Software.
    If you intend to DROP the Databases, and if these Databases were created by DBCA, you may use DBCA to DROP them. If the Databases were created manually you have the DROP DATABASE statement as follow:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_8009.htm
    About the Software, the answer depends on the Oracle Release.
    In Oracle *11.1*, OUI let you deinstall the Oracle installation.
    In Oracle *11.2*, you need to use the Oracle De-install Utility (11.2.0.1.0) for Microsoft Windows.
    Hope this help.
    Best regards,
    Jean-Valentin

  • Problem in deleting child record

    Hi,
    I have a requirement to remove the child records.
    I have two database tables (without any foreign key or database constraints). I have created EOs (ParentEO and ChildEO) and Association. I have created view objects (ParentVO with a transient attribute called "SelectFlag" and ChildVO) based on EOs.
    I have created a MollyViewLink and created Application module (MollyAM) .VOs are associated with AM.
    For detail records, I have created delete icon and I have written below code to handle the deleteChild event in detail region's controller:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if ("deleteChild".equals(pageContext.getParameter(EVENT_PARAM)))
    MollyAMImpl am = (MollyAMImpl)pageContext.getApplicationModule(webBean);
    String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    System.out.println("Child ROW Reference =="+rowReference);
    MollyUserDetailsVORowImpl voRow = (MollyUserDetailsVORowImpl)am.findRowByRef(rowReference);
    String parentID = voRow.getId().toString();
    System.out.println("ID is : "+ parentID);
    voRow.remove();
    System.out.println("Child row deleted successfully...");
    am.getTransaction().commit();
    When I click on delete icon at child record, I get below SOP messages:
    Child ROW Reference ==MollyAM.MollyUserDetailsVO_MollyViewLink_MollyUserDetailsVO:MollyUserDetailsVO_MollyViewLink_MollyUserDetailsVO_0{null}
    ID is : 52
    Child row deleted successfully...
    Child record is also being removed from UI. But when I query the database, I can still see the records there. For me, it seems like commit is not affecting the child table.
    Similar code to delete the parent record is working fine.
    Thanks!!!

    Hi Vinod ,
    I am deleting condition record number if  know any function module  please let me know
    problem happing in PRD for particular condition numer it showing INTERNAL ERROR (This is the condition table A923)
    that condition number is their in KONH but not their in KONP because of that  INTERNAL ERROR occuring
    for that i have writen code for that deleting the condition number  ....
    if know any thing please let me know

  • Does not delete child records - ADF-BC

    I am using ADF-BC to display data from three tables.
    I have a main view and a two view links to the children. when I try to delete the master record it says - Integrity constraint violated - child record found. And one more thing even though it does not delete the child records it deletes the master record from the view (only form the view, not from the database).
    How can I make it delete the child record first.
    Thanks

    I did the while exercise one more time and it started working. thanks.
    Now I have another problem. I have to keep that commit button on the page. If I delete the comit button from the page it gives me nullpointer exception at the line
    operationBinding = bindings.getOperationBinding("Commit");
    How can I solve this
    Thanks

  • How to obtain parent record from child record in relationship using API

    Hi,
    I have a record in the main table that is the child in a parent/child relationship to another main table record.  Using the Java API, how would I obtain the parent record in the relationship where I am starting with the child record?  In the API there seems to just be calls for getChildren, but not a getParent type call.
    Appreciate any immediate help that can be provided.
    Thanks,
    Eddie

    Hi Eddie,
    Please follow the below steps to retrieve only parents of a child Record.
    1. Create RetrieveRelationshipsCommand.
    2. Set the parameter RelationshipId.
    3. Set the parameter Anchor Record and Anchor Record Id. In this case the child record for which parents records to be retrieved.
    4. Set the parameter setGetChildren as false . This retrieves only the parent records for the specified child reocrd.
    5. Execute the RetrieveRelationshipsCommand.
    6. Retrieve member records from above step.
    Hope it helps
    Regards,
    Neeharika

  • Deleting a user in AD using Oracle Workflow

    Hello.
    I have a very unusual scenario that I want to solve.
    We are developing an application using Oracle Workflow in which we are simulating the process of deleting a user from several systems. In one of the steps of the process we have to invalidate the user in MS Active Directory.
    Using OID it's possible to do that? Any clues on how to do it?
    Thanks In Advice.

    adi,
    Yes, the Change User Password workflow is called even if the user logged in using "forgot my password" questions.
    By default, IDM commits the user passwords before the "Change User Password" WF is called (unless you set the deferCommit option), so the problem may be that your function isn't getting called or receiving valid input. Can you verify that your code is actually called?
    The workflow goes like this: (1) Start; If there's an uncommitted password view (there isn't by default) -> (2) CommitView -> (3) Now reprovision the user.
    If you're depending on the transition to CommitView, that may be why your code isn't being called.

Maybe you are looking for