Recursive deletion of parent table

Hi Experts,
for example one master table (emp) and related child table like dept and these related child table like one more table so .....on
so i want delete the child table records as per master table(not delete the master only related child table records as per primary key)
please tel me query or procedure urgently

983376 wrote:
or example one master table (emp) and related child table like dept and these related child table like one more table so .....onHuh. How can the emp table be a parent table and the dept table a child table?
The child table has the parent's primary key in order for it to relate to its parent. Does the dept table (child) have emp table (parent) primary keys as reference, in order for the child to identify its parent? No, it does not.
So how can the emp table be the parent and the dept table the child?
Do you even understand what a parent-child relationship is, or are you guessing?
so i want delete the child table records as per master table(not delete the master only related child table records as per primary key)You use a DELETE SQL statement on the child table, specifying the parent key value of the rows (children) to delete. A siimple:
DELETE FROM child_table WHERE parent_key = :bindValue
please tel me query or procedure urgentlyThere is no "+urgent+" here. This is a forum of volunteers, giving you the benefit of their knowledge and experience for free, in their free time.
It is very arrogant and unacceptable to demand an urgent answer from this forum.

Similar Messages

  • Can't delete from parent table if FK constraint on the out-of-line table

    Using Oracle XML DB 11g
    I am using out-of-line storage table to store a collection of XML elements in conjuction with storeVarrayAsTable="true". So what I have is a parent table containing a nested table of VARRAY of REFs to rows in the out-of-line table.
    In addition, I have a foreign key constraint placed on a column in the out-of-line table.
    My problem is that I am not able to delete rows from the parent table when the FK constraint is placed on the out-of-line table. Only when I drop the FK constraint does the deletion work - all associated rows in the nested table and out-of-line table
    gets deleted correctly.
    With the FK constraint, deleting the child document like this
    dbms_xdb.deleteResource('/project-1.xml')
    gives me this error:
    ORA-31018: Error deleting XML document
    ORA-03001: unimplemented feature
    *Cause:  The XMLType object pointed to by the given REF could not
    be deleted because either the REF was invalid or it pointed to a non-existent table.
         *Action:  Either use FORCE deletion or supply a valid REF.
    I have tried deleting with the FORCE options as well with no success.
    Using DBMS_XDB.DELETE_RECURSIVE_FORCE option doesn't produce an error, but doesn't perform the deletion either.
    Here is the XML Schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xlink="http://www.w3.org/1999/xlink"
    elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true">
    <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>
    <xs:element name="project" xdb:defaultTable="PROJECT_TAB">
    <xs:complexType xdb:SQLType="PROJECT_TYP">
    <xs:sequence>
    <xs:element name="resourceList" minOccurs="0" xdb:SQLName="RESOURCE_LIST">
    <xs:complexType xdb:SQLType="RESOURCE_LIST_TYP">
    <xs:sequence>
    <xs:element name="aResource" type="refType" minOccurs="0" maxOccurs="unbounded" xdb:SQLInline="false"
    xdb:SQLName="A_RESOURCE_REF" xdb:defaultTable="RESOURCE_REF_TAB"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="aguid" type="xs:string" use="required" xdb:SQLName="AGUID"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="aResource" xdb:defaultTable="A_RESOURCE_TAB">
    <xs:complexType xdb:SQLType="A_RESOURCE_TYP">
    <xs:complexContent>
    <xs:extension base="contactType">
    <xs:attribute name="aguid" type="xs:string" use="required" xdb:SQLName="AGUID"/>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    </xs:element>
    <xs:complexType name="contactType" xdb:SQLType="CONTACT_TYP">
    <xs:sequence>
    <xs:element name="name" type="xs:string" xdb:SQLName="NAME"/>
    <xs:element name="email" type="xs:string" minOccurs="0" xdb:SQLName="EMAIL"/>
    <xs:element name="phone" type="xs:string" xdb:SQLName="PHONE"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="refType" xdb:SQLType="REF_TYP">
    <xs:attribute ref="xlink:href" use="required"/>
    <xs:attribute name="oref" type="xs:string" use="optional" xdb:SQLName="OREF"/>
    </xs:complexType>
    </xs:schema>
    I registered the schema using structured storage with these options:
    BEGIN
    DBMS_XMLSCHEMA.registerschema(
    SCHEMAURL => 'LSDProjects.xsd',
    SCHEMADOC => xdbURIType('/home/LSDProject2/LSDProjects.xsd').getClob(),
    LOCAL => TRUE, -- local
    GENTYPES => TRUE, -- generate object types
    GENBEAN => FALSE, -- no java beans
    GENTABLES => TRUE -- generate object tables
    END;
    The PK and FK constraints were added like this:
    -- Add PK constraints on aResource/@aguid attributes
    ALTER TABLE A_RESOURCE_TAB ADD CONSTRAINT A_RESOURCE_AGUID_IS_UNIQUE UNIQUE (XMLDATA."AGUID");
    -- Add FK constraint on out-of-line table
    ALTER TABLE RESOURCE_REF_TAB
    ADD (CONSTRAINT ref_resource_aguid_is_valid FOREIGN KEY (XMLDATA."OREF")
    REFERENCES A_RESOURCE_TAB(XMLDATA."AGUID"));
    Here are the XML instance documents:
         where resource-1.xml looks like this :
    <aResource aguid="resource-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LSDProjects.xsd">
         <name>Jane Doe</name>
         <email>[email protected]</email>
    <phone/>
    </aResource>
         and project-1.xml looks like this :
         <project aguid="project-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LSDProjects.xsd"
                   xmlns:xlink="http://www.w3.org/1999/xlink">               
              <resourceList>
                   <aResource xlink:href="/resource-1.xml" oref="resource-1"/>                         
              </resourceList>     
         </project>
    where <project> document contains a collection of <aResource> elements stored in the out-of-line table and
    project/@oref attribute is a foreign key to the primary aResource/@aguid attribute.
    Can someone shed some light on why I am unable to delete "project-1.xml" from the repository when the FK constraint is applied onto the out-of-line table.
    Any advice/suggestions would be appreciated. Thanks!

    Thank you for the quick reply, mdrake.
    I am currently prototyping and testing out (best) ways to achieve data integrity with XML data in XML DB.
    I have instance documents that makes cross references to values in other instance documents
    (not of the same root nodes). What I'm trying to enforce is a referential constraint between the documents
    so that a document cannot be inserted if the referenced document doesn't exists.
    In this situation, a <project> document contains a collection of elements with @oref attributes.
    The collection is stored in an out-of-line table.
    For example:
    <project>
    <resourceList>
    <aResource ... oref="resource-1"/>
    <aResource ... oref="resource-2"/>
    </resourceList>
    </project>
    The @oref (FK) attribute above references a @aguid (PK) attribute in <aResource> document (below):
    <aResource aguid="resource-1"> .... </aResource>
    Basically, I want to ensure that the value of
    /project/resourceList/aResource/@oref
    correspond to a valid
    /aResource/@aguid
    Note that I was able to add the FK constraint on the OOL table without any issues.
    And the constraint did work as expected as I was not allowed to insert a <project> document
    that referenced a non-existent /aResource/@aguid.
    The problem was that I could not delete the <project> document from the XML DB repository
    once the FK contraint was added. Deleting with the DELETE_RECURSIVE_FORCE option did not give
    me any errors - is just didn't do anything.
    I guess there are certain limitations with using out-of-line tables.
    BTW, sorry the examples are hard to read as the indentations are removed when posting.

  • Deletion from parent table

    Hi,
    Is it possible to delete parent records from parent table without deleting from child tables ?
    I can delete the records after disabling the constraints . But I couldn't enable the constraint on child table after deletion of parent records from parent table.
    Please Help.

    Two Alternatives
    1. What is the need of child records if no parent record ? No use keeping the child records without parent records.
    For e.g., If we have Invoice_Master containing the Distributor and total amount and Other Transport details and Invoice_Details containing the list of Items the Distributor has purchased. In this case if we delete the Invoice_Master then the Invoice_Details is meaning less.
    2. Another case If really need to maintain the Child records then create one dummy record in the Parent and link the Child records to the dummy Parent by changing the Foreign Key value to the dummy Parent record Primary Key Value.

  • Recursive deletion of master table

    Hi experts,
    I want clearly fully procedure for recursive deletion master table(through primary key)

    Duplicate thread
    {message:id=10817502}
    Repeated posting of Duplicate questions is not going to help you. So, I would suggest to stick to a single thread, provide all necessary details and try the links/solutions posted.

  • Delete the parent record

    hi all,
    based on the thread i got the list of child tables.
    Re: to find the tables which is having link with particular table.
    no i have doubt in deletion process.
    My ultimate aim is to delete the bl_det records.
    let me explain with ex.
    i have table
    BL_DET --parent table with comp and ref as primary key
    which is having child rec.
    BL_CON --child of BL_DET(comp,ref) primary key comp,ref and serial
    BL_CON_PCK --is child of BL_CON(comp,ref,serial) primary key comp,ref,serial,pck_gp_srl,gp_srl.
    DELETE BL_CON_PCK
    WHERE BCK_COMP = :GLOBAL.comp
    AND BCK_REF = :parameter;
    DELETE FROM BL_CON
    WHERE BCR_COMP = :GLOBAL.comp
    AND BCR_REF = :paramter
    DELETE FROM BL_DET
    WHERE BL_COMP = :GLOBAL.comp
    AND BL_REF - :parameterwill delete the correct set of records.(my doubt area is delete statement written for the table BL_CON_PCK).
    Please tell me if i am wrong.
    Thanks..

    (my doubt area is delete statement written for the table BL_CON_PCK).Cannot understand your doubt. What is your doubt, are you getting any error while executing your code?
    To delete a record from parent table all child references must be deleted. So your delete statement appears right
    -- How delete should progress
    BL_CON_PCK >> BL_CON >> BL_DET
    {code}
    If you have created foreign constraint using ON DELETE CASCADE or ON DELETE SET NULL then you can straight away delete from parent table and all child references are deleted/set as null respectively. Read Oracle Documentation to see details
    Short demonstration
    {code:sql}
    SQL> CREATE TABLE A(a1 NUMBER PRIMARY KEY , a2 NUMBER);
    Table created
    SQL>  CREATE TABLE B(b1 NUMBER PRIMARY KEY , a1 NUMBER);
    Table created
    SQL>  CREATE TABLE C(c1 NUMBER, b1 NUMBER);
    Table created
    SQL>  ALTER TABLE B ADD CONSTRAINT FK_B FOREIGN KEY (a1) REFERENCES A ON DELETE CASCADE;
    Table altered
    SQL>  ALTER TABLE C ADD CONSTRAINT FK_C FOREIGN KEY (b1) REFERENCES B ON DELETE CASCADE;
    Table altered
    SQL>  INSERT INTO A VALUES (1,2);
    1 row inserted
    SQL>  INSERT INTO B VALUES (3,1);
    1 row inserted
    SQL>  INSERT INTO C VALUES (4,3);
    1 row inserted
    SQL>  SELECT * FROM A;
            A1         A2
             1          2
    SQL>  SELECT * FROM B;
            B1         A1
             3          1
    SQL>  SELECT * FROM C;
            C1         B1
             4          3
    SQL>  DELETE FROM A WHERE A1=1;
    1 row deleted
    SQL>  SELECT * FROM A;
            A1         A2
    SQL>  SELECT * FROM B;
            B1         A1
    SQL>  SELECT * FROM C;
            C1         B1
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to delete the duplicate rows present in the parent table & insert the latest duplicate record into the parent table linked with the child table.

    I have a master table and i need to import the rows into the parent and child table.
    Master table name is Flatfile_Inventory
    Parent Table name is INVENTORY
    Child Tables name are INVENTORY_AMOUNT,INVENTORY_DETAILS,INVENTORY_VEHICLE,
    Error details will be goes to LOG_INVENTORY_ERROR
    I have 4 duplicate rows in the Flatfile_Inventory which i have already inserted in the Parent and child table.
    Again when i run the query using stored procedure,
    its tells that all the 4 rows are duplicate and will move to the Log_Inventory_Error.
    I need is if i have the duplicate rows in the flatfile_Inventory when i start inserting into the parent and child table the already inserted row have the unique ID i
    must identify it and delete that row in the both parent and chlid table.And latest row must get inserted into the Parent and child table from Flatfile_Inventory.
    Please help me to write the query i have attached the Full stored procedure Script..
    Arunraj Kumar

    Hi Santhosh,
    This is my Script.
    -- =============================================
    -- Stored Procedure for FLATFILE_INVENTORY
    -- =============================================
    -- Drop stored procedure if it already exists
       DROP PROCEDURE SP_Flatfile_Inventory
    GO
    CREATE PROCEDURE SP_Flatfile_Inventory
    AS
    --USE IconicMarketing
    GO
    DECLARE
    @FileType  varchar(50)  ,
    @ACDealerID  varchar(50)  ,
    @ClientDealerID  varchar(50)  ,
    @DMSType  varchar(50)  ,
    @StockNumber  varchar(50)  ,
    @InventoryDate  datetime  ,
    @StockType  varchar(100)  ,
    @DMSStatus  varchar(50)  ,
    @InvoicePrice  numeric(18, 2)  ,
    @CostPack  varchar(50)  ,
    @SalesCost  numeric(18, 2)  ,
    @HoldbackAmount  numeric(18, 2)  ,
    @ListPrice  numeric(18, 2)  ,
    @MSRP  varchar(max)  ,
    @LotLocation  varchar(50)  ,
    @TagLine  varchar(max)  ,
    @Certification  varchar(max)  ,
    @CertificationNumber  varchar(max)  ,
    @VehicleVIN  varchar(50)  ,
    @VehicleYear  bigint  ,
    @VehicleMake  varchar(50)  ,
    @VehicleModel  varchar(50)  ,
    @VehicleModelCode  varchar(50)  ,
    @VehicleTrim  varchar(50)  ,
    @VehicleSubTrimLevel  varchar(max)  ,
    @Classification  varchar(max)  ,
    @TypeCode  varchar(100)  ,
    @VehicleMileage  bigint  ,
    @EngineCylinderCount  bigint  ,
    @TransmissionType  varchar(50)  ,
    @VehicleExteriorColor  varchar(50)  ,
    @VehicleInteriorColor  varchar(50)  ,
    @CreatedDate  datetime  ,
    @LastModifiedDate  datetime  ,
    @ModifiedFlag  varchar(max)  ,
    @InteriorColorCode  varchar(50)  ,
    @ExteriorColorCode  varchar(50)  ,
    @PackageCode  varchar(50)  ,
    @CodedCost  varchar(50)  ,
    @Air  varchar(100)  ,
    @OrderType  varchar(max)  ,
    @AgeDays  bigint  ,
    @OutstandingRO  varchar(50)  ,
    @DlrAccessoryRetail  varchar(50)  ,
    @DlrAccessoryCost  varchar(max)  ,
    @DlrAccessoryDesc  varchar(max)  ,
    @ModelDesc  varchar(50)  ,
    @Memo1  varchar(1000)  ,
    @Memo2  varchar(max)  ,
    @Weight  varchar(max)  ,
    @FloorPlan  numeric(18, 2)  ,
    @Purchaser  varchar(max)  ,
    @PurchasedFrom  varchar(max)  ,
    @InternetPrice  varchar(50)  ,
    @InventoryAcctDollar  numeric(18, 2)  ,
    @VehicleType  varchar(50)  ,
    @DealerAccessoryCode  varchar(50)  ,
    @AllInventoryAcctDollar  numeric(18, 2)  ,
    @BestPrice  varchar(50)  ,
    @InStock  bigint  ,
    @AccountingMake  varchar(50)  ,
    @GasDiesel  varchar(max)  ,
    @BookValue  varchar(10)  ,
    @FactoryAccessoryDescription  varchar(max)  ,
    @TotalReturn  varchar(10)  ,
    @TotalCost  varchar(10)  ,
    @SS  varchar(max)  ,
    @VehicleBody  varchar(max)  ,
    @StandardEquipment  varchar(max)  ,
    @Account  varchar(max)  ,
    @CalculatedPrice  varchar(10)  ,
    @OriginalCost  varchar(10)  ,
    @AccessoryCore  varchar(10)  ,
    @OtherDollar  varchar(10)  ,
    @PrimaryBookValue  varchar(10)  ,
    @AmountDue  varchar(10)  ,
    @LicenseFee  varchar(10)  ,
    @ICompany  varchar(max)  ,
    @InvenAcct  varchar(max)  ,
    @Field23  varchar(max)  ,
    @Field24  varchar(max)  ,
    @SalesCode  varchar(max)  ,
    @BaseRetail  varchar(10)  ,
    @BaseInvAmt  varchar(10)  ,
    @CommPrice  varchar(10)  ,
    @Price1  varchar(10)  ,
    @Price2  varchar(10)  ,
    @StickerPrice  varchar(10)  ,
    @TotInvAmt  varchar(10)  ,
    @OptRetail  varchar(max)  ,
    @OptInvAmt  varchar(10)  ,
    @OptCost  varchar(10)  ,
    @Options  varchar(max)  ,
    @Category  varchar(max)  ,
    @Description  varchar(max)  ,
    @Engine  varchar(max)  ,
    @ModelType  varchar(max)  ,
    @FTCode  varchar(max)  ,
    @Wholesale  varchar(max)  ,
    @Retail  varchar(max)  ,
    @Draft  varchar(max)  ,
    @Inventoryid int;
    DECLARE Inventory_Cursor CURSOR FOR 
    SELECT * from [dbo].[FLATFILE_INVENTORY];
    OPEN Inventory_Cursor
    FETCH NEXT FROM Inventory_Cursor 
    INTO @FileType   ,
    @ACDealerID     ,
    @ClientDealerID     ,
    @DMSType     ,
    @StockNumber     ,
    @InventoryDate    ,
    @StockType    ,
    @DMSStatus     ,
    @InvoicePrice     ,
    @CostPack     ,
    @SalesCost     ,
    @HoldbackAmount     ,
    @ListPrice     ,
    @MSRP     ,
    @LotLocation     ,
    @TagLine     ,
    @Certification     ,
    @CertificationNumber     ,
    @VehicleVIN     ,
    @VehicleYear     ,
    @VehicleMake     ,
    @VehicleModel     ,
    @VehicleModelCode     ,
    @VehicleTrim     ,
    @VehicleSubTrimLevel     ,
    @Classification     ,
    @TypeCode    ,
    @VehicleMileage     ,
    @EngineCylinderCount     ,
    @TransmissionType     ,
    @VehicleExteriorColor     ,
    @VehicleInteriorColor     ,
    @CreatedDate    ,
    @LastModifiedDate    ,
    @ModifiedFlag     ,
    @InteriorColorCode     ,
    @ExteriorColorCode     ,
    @PackageCode     ,
    @CodedCost     ,
    @Air    ,
    @OrderType     ,
    @AgeDays     ,
    @OutstandingRO     ,
    @DlrAccessoryRetail     ,
    @DlrAccessoryCost     ,
    @DlrAccessoryDesc     ,
    @ModelDesc     ,
    @Memo1 ,
    @Memo2     ,
    @Weight     ,
    @FloorPlan     ,
    @Purchaser     ,
    @PurchasedFrom     ,
    @InternetPrice     ,
    @InventoryAcctDollar     ,
    @VehicleType     ,
    @DealerAccessoryCode     ,
    @AllInventoryAcctDollar     ,
    @BestPrice     ,
    @InStock     ,
    @AccountingMake     ,
    @GasDiesel     ,
    @BookValue     ,
    @FactoryAccessoryDescription     ,
    @TotalReturn     ,
    @TotalCost     ,
    @SS     ,
    @VehicleBody     ,
    @StandardEquipment     ,
    @Account     ,
    @CalculatedPrice     ,
    @OriginalCost     ,
    @AccessoryCore     ,
    @OtherDollar     ,
    @PrimaryBookValue     ,
    @AmountDue     ,
    @LicenseFee     ,
    @ICompany     ,
    @InvenAcct     ,
    @Field23     ,
    @Field24     ,
    @SalesCode     ,
    @BaseRetail     ,
    @BaseInvAmt     ,
    @CommPrice     ,
    @Price1     ,
    @Price2     ,
    @StickerPrice     ,
    @TotInvAmt     ,
    @OptRetail     ,
    @OptInvAmt     ,
    @OptCost     ,
    @Options     ,
    @Category     ,
    @Description     ,
    @Engine     ,
    @ModelType     ,
    @FTCode     ,
    @Wholesale     ,
    @Retail     ,
    @Draft     ;
    WHILE @@FETCH_STATUS = 0
    BEGIN
        PRINT @VehicleVIN    ;
    -- ****************** insert into Inventory Table ***********
    INSERT INTO INVENTORY 
    IconicDealerID,
    StockNumber,
    DMSType,
    InventoryDate
    VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate);
    set @Inventoryid = scope_identity();
    PRINT @Inventoryid;
    --Insert into Inventory_Details Table
    INSERT INTO [INVENTORY_DETAILS]
    InventoryID,
    StockType,
    DMSStatus,
    LotLocation,
    TagLine,
    Certification,
    CertificationNumber,
    CreatedDate,
    LastModifiedDate,
    ModifiedFlag,
    PackageCode,
    OrderType,
    AgeDays,
    OutstandingRO,
    Memo1,
    Memo2,
    Purchaser,
    PurchasedFrom,
    DealerAccessoryCode,
    InStock,
    AccountingMake,
    SS,
    Account,
    AccessoryCore,
    ICompany,
    InvenAcct,
    Field23,
    Field24,
    SalesCode,
    Draft,
    FTCode
    VALUES (
    @InventoryID,
    @StockType,
    @DMSStatus,
    @LotLocation,
    @TagLine,
    @Certification,
    @CertificationNumber,
    @CreatedDate,
    @LastModifiedDate,
    @ModifiedFlag,
    @PackageCode,
    @OrderType,
    @AgeDays,
    @OutstandingRO,
    @Memo1,
    @Memo2,
    @Purchaser,
    @PurchasedFrom,
    @DealerAccessoryCode,
    @InStock,
    @AccountingMake,
    @SS,
    @Account,
    @AccessoryCore,
    @ICompany,
    @InvenAcct,
    @Field23,
    @Field24,
    @SalesCode,
    @Draft,
    @FTCode
    --Insert into Inventory_Amount Table
    INSERT INTO [dbo].[INVENTORY_AMOUNT]
    InventoryID,
    AllInventoryAcctDollar,
    OtherDollar,
    PrimaryBookValue,
    AmountDue,
    LicenseFee,
    CalculatedPrice,
    OriginalCost,
    BookValue,
    TotalReturn,
    TotalCost,
    DlrAccessoryRetail,
    DlrAccessoryCost,
    DlrAccessoryDesc,
    InternetPrice,
    InventoryAcctDollar,
    BestPrice,
    Weight,
    FloorPlan,
    CodedCost,
    InvoicePrice,
    CostPack,
    SalesCost,
    HoldbackAmount,
    ListPrice,
    MSRP,
    BaseRetail,
    BaseInvAmt,
    CommPrice,
    Price1,
    Price2,
    StickerPrice,
    TotInvAmt,
    OptRetail,
    OptInvAmt,
    OptCost,
    Wholesale,
    Retail
    VALUES (
    @InventoryID,
    @AllInventoryAcctDollar,
    @OtherDollar,
    @PrimaryBookValue,
    @AmountDue,
    @LicenseFee,
    @CalculatedPrice,
    @OriginalCost,
    @BookValue,
    @TotalReturn,
    @TotalCost,
    @DlrAccessoryRetail,
    @DlrAccessoryCost,
    @DlrAccessoryDesc,
    @InternetPrice,
    @InventoryAcctDollar,
    @BestPrice,
    @Weight,
    @FloorPlan,
    @CodedCost,
    @InvoicePrice,
    @CostPack,
    @SalesCost,
    @HoldbackAmount,
    @ListPrice,
    @MSRP,
    @BaseRetail,
    @BaseInvAmt,
    @CommPrice,
    @Price1,
    @Price2,
    @StickerPrice,
    @TotInvAmt,
    @OptRetail,
    @OptInvAmt,
    @OptCost,
    @Wholesale,
    @Retail
    --Insert into Inventory_Vehicle Table
    INSERT INTO [dbo].[INVENTORY_VEHICLE]
    InventoryID,
    InteriorColorCode,
    ExteriorColorCode,
    Air,
    ModelDesc,
    VehicleType,
    VehicleVIN,
    VehicleYear,
    VehicleMake,
    VehicleModel,
    VehicleModelCode,
    VehicleTrim,
    VehicleSubTrimLevel,
    Classification,
    TypeCode,
    VehicleMileage
    VALUES (
    @InventoryID,
    @InteriorColorCode,
    @ExteriorColorCode,
    @Air,
    @ModelDesc,
    @VehicleType,
    @VehicleVIN,
    @VehicleYear,
    @VehicleMake,
    @VehicleModel,
    @VehicleModelCode,
    @VehicleTrim,
    @VehicleSubTrimLevel,
    @Classification,
    @TypeCode,
    @VehicleMileage
    -- Move cursor to Next record 
        FETCH NEXT FROM Inventory_Cursor 
    INTO @FileType   ,
    @ACDealerID     ,
    @ClientDealerID     ,
    @DMSType     ,
    @StockNumber     ,
    @InventoryDate    ,
    @StockType    ,
    @DMSStatus     ,
    @InvoicePrice     ,
    @CostPack     ,
    @SalesCost     ,
    @HoldbackAmount     ,
    @ListPrice     ,
    @MSRP     ,
    @LotLocation     ,
    @TagLine     ,
    @Certification     ,
    @CertificationNumber     ,
    @VehicleVIN     ,
    @VehicleYear     ,
    @VehicleMake     ,
    @VehicleModel     ,
    @VehicleModelCode     ,
    @VehicleTrim     ,
    @VehicleSubTrimLevel     ,
    @Classification     ,
    @TypeCode    ,
    @VehicleMileage     ,
    @EngineCylinderCount     ,
    @TransmissionType     ,
    @VehicleExteriorColor     ,
    @VehicleInteriorColor     ,
    @CreatedDate    ,
    @LastModifiedDate    ,
    @ModifiedFlag     ,
    @InteriorColorCode     ,
    @ExteriorColorCode     ,
    @PackageCode     ,
    @CodedCost     ,
    @Air    ,
    @OrderType     ,
    @AgeDays     ,
    @OutstandingRO     ,
    @DlrAccessoryRetail     ,
    @DlrAccessoryCost     ,
    @DlrAccessoryDesc     ,
    @ModelDesc     ,
    @Memo1 ,
    @Memo2     ,
    @Weight     ,
    @FloorPlan     ,
    @Purchaser     ,
    @PurchasedFrom     ,
    @InternetPrice     ,
    @InventoryAcctDollar     ,
    @VehicleType     ,
    @DealerAccessoryCode     ,
    @AllInventoryAcctDollar     ,
    @BestPrice     ,
    @InStock     ,
    @AccountingMake     ,
    @GasDiesel     ,
    @BookValue     ,
    @FactoryAccessoryDescription     ,
    @TotalReturn     ,
    @TotalCost     ,
    @SS     ,
    @VehicleBody     ,
    @StandardEquipment     ,
    @Account     ,
    @CalculatedPrice     ,
    @OriginalCost     ,
    @AccessoryCore     ,
    @OtherDollar     ,
    @PrimaryBookValue     ,
    @AmountDue     ,
    @LicenseFee     ,
    @ICompany     ,
    @InvenAcct     ,
    @Field23     ,
    @Field24     ,
    @SalesCode     ,
    @BaseRetail     ,
    @BaseInvAmt     ,
    @CommPrice     ,
    @Price1     ,
    @Price2     ,
    @StickerPrice     ,
    @TotInvAmt     ,
    @OptRetail     ,
    @OptInvAmt     ,
    @OptCost     ,
    @Options     ,
    @Category     ,
    @Description     ,
    @Engine     ,
    @ModelType     ,
    @FTCode     ,
    @Wholesale     ,
    @Retail     ,
    @Draft     ;
    END 
    CLOSE Inventory_Cursor;
    DEALLOCATE Inventory_Cursor;
    GO
    SET ANSI_PADDING OFF
    GO
    Arunraj Kumar

  • Delete the parent records and child table records at a time

    hi all;
    I am facing the pbm like to delete the all records in child table and corresponding records in parent table at a time. so I want to delete the all the records in child table and corresponding parent records in parent table by using single SQL query. plz help me
    Thanks in advance

    You want to use one single SQL statement to delete the child records in a table and the corresponding master records in the master table??
    That's not quite possible with a single SQL, of course unless you are talking about Oracle Forms, where you have a relation and set the delete behavior to Cascading, like said in the above posts.
    Tony

  • Deleting a row from parent table

    Dear Guru's
    I am having two table with parent - child relationship. My problem is when I am deleting a row from parent table the curresponding child row from child table also should be deleted.
    My Primary table 'Employee, EMPID Primary key
    Child table 'Privilage' inthis EMPID referencing the EMPID of Employee table
    My need is when I am deleting a row from parent table the curresponding child row from child table also should be deleted
    I issued the SQL query like,
    delete from employee where empid='12345' cascade constraints;
    Then it showing me error like,
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    Please resolve my issue , Its Top urgent
    Thanks & Cheers
    Antony

    Choosing How Foreign Keys Enforce Referential Integrity
    Oracle Database allows different types of referential integrity actions to be enforced, as specified with the definition of a FOREIGN KEY constraint:
    Prevent Delete or Update of Parent Key The default setting prevents the deletion or update of a parent key if there is a row in the child table that references the key. For example:
    CREATE TABLE Emp_tab ( 
    FOREIGN KEY (Deptno) REFERENCES Dept_tab);Delete Child Rows When Parent Key Deleted The ON DELETE CASCADE action allows parent key data that is referenced from the child table to be deleted, but not updated. When data in the parent key is deleted, all rows in the child table that depend on the deleted parent key values are also deleted. To specify this referential action, include the ON DELETE CASCADE option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE CASCADE); Set Foreign Keys to Null When Parent Key Deleted The ON DELETE SET NULL action allows data that references the parent key to be deleted, but not updated. When referenced data in the parent key is deleted, all rows in the child table that depend on those parent key values have their foreign keys set to null. To specify this referential action, include the ON DELETE SET NULL option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE SET NULL);
    SQL> conn scott/tiger
    Connected.
    SQL> create table ppk ( no number primary key);
    Table created.
    SQL> begin for inn in 1..10 loop insert into ppk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> create table ffk ( no number references ppk(no));
    Table created.
    SQL> begin for inn in 1..10 loop insert into ffk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> drop table ppk cascade constraints;
    Table dropped.Message was edited by:
    user52
    Message was edited by:
    user52
    Message was edited by:
    user52

  • How to delete parent table data even though it has child records

    hi all,
    How to delete parent table data even though it has child records.
    ex: delete from pa_request cascade constraints;
    But this command is not working .
    Regards,
    P Prakash

    833560 wrote:
    ex: delete from pa_request cascade constraints;cascade constraints is DROP table option. It can't be used with DELETE. You need to delete child rows first or drop foreign keys and recreate them with ON DELETE CASCADE. Then:
    delete from pa_request will automatically delete child rows. However, personally I don't like ON DELETE CASCADE. You can, by mistake, delete half of your database without even realizing it.
    SY.

  • Creating a Trigger for Deleting the records from a parent Table

    I am new to creating Trigger
    We will need several small tables that will be used to store any records that are deleted by the owner of the table. These will likely need a trigger where we would Delete from the parent table and on that Delete populate the child table with the previous record's data.
    Please give me a pseudo code for this
    Thanks
    John
    Edited by: user10750995 on Dec 30, 2008 9:06 AM

    Something like this:
    CREATE OR REPLACE TRIGGER trg_my_table_hist
    AFTER DELETE
    ON my_table
    FOR EACH ROW
    BEGIN
    INSERT INTO Hist_MyTable
    ( column1, column2, ..., DELETION_DATE)
    VALUES
    (:OLD.column1, :OLD.column2, ...., SYSDATE);
    END;
    /My_Table is your main table. When a row is deleted, the trigger will be fired and copy the deleted row to another table called Hist_My_Table. I'm supposing that the history table has all columns as they are defined in main tables plus a column named DELETION_DATE.
    My experience indicates that, probably, it's a good idea maintain update history and the user. But it depends on your requests.
    Regards,
    Miguel

  • Deleting records from child to parent table

    I have ran into a situation where i will have to delete all the records of the child table and then the records of parent table and i was able to write a query to get the column,table both for parent,child and stuck up in deleting them using query and
    i will not be able to use Cascade...My validation criteria is applicable for the child tables and parent table...am trying to compare last modified date of each table...Kindly help me with an approach
    DECLARE @mytable VARCHAR(30) SET @mytable = 'tablea'
    DECLARE @Order INT SET @Order = 0
    DECLARE @Count INT
    declare @tblname varchar(100),@query NVARCHAR(max),@parent varchar(100)
    if OBJECT_ID('tempdb..#OrderList','U') is not null
    DROP TABLE #OrderList
    if OBJECT_ID('tempdb..#temp','U') is not null
    DROP TABLE #temp
    CREATE TABLE #TEMP
    OrderNo INT,
    TableName VARCHAR(50),
    tid varchar(100),
    childtable varchar(100),
    cid varchar(100)
    CREATE TABLE #OrderList
    RecordNo INT,
    OrderNo INT,
    TableName VARCHAR(50),
    tid varchar(100),
    childtable varchar(100),
    cid varchar(100)
    create table #t
    taname varchar(100)
    ;with tempcte (level,parent,pcol,child,ccol)
    as
    SELECT 0,SO2.name, SC2.name,SO1.name, SC1.name
    FROM dbo.sysforeignkeys FK
    INNER JOIN dbo.syscolumns SC1
    ON FK.fkeyid = SC1.id AND FK.fkey = SC1.colid
    INNER JOIN dbo.syscolumns SC2
    ON FK.rkeyid = SC2.id AND FK.rkey = SC2.colid
    INNER JOIN dbo.sysobjects SO1
    ON FK.fkeyid = SO1.id
    INNER JOIN dbo.sysobjects SO2
    ON FK.rkeyid = SO2.id
    INNER JOIN dbo.sysobjects FO
    ON FK.constid = FO.id
    WHERE SO2.Name = 'tablea'
    union all
    SELECT level+1,SO2.name, SC2.name,SO1.name, SC1.name
    FROM dbo.sysforeignkeys FK
    INNER JOIN dbo.syscolumns SC1
    ON FK.fkeyid = SC1.id AND FK.fkey = SC1.colid
    INNER JOIN dbo.syscolumns SC2
    ON FK.rkeyid = SC2.id AND FK.rkey = SC2.colid
    INNER JOIN dbo.sysobjects SO1
    ON FK.fkeyid = SO1.id
    INNER JOIN dbo.sysobjects SO2
    ON FK.rkeyid = SO2.id
    INNER JOIN dbo.sysobjects FO
    ON FK.constid = FO.id
    inner join tempcte t
    on SO2.Name = t.child
    insert into #TEMP
    OrderNo,
    TableName,
    tid,
    childtable,
    cid
    select
    level,parent,pcol,child,ccol from tempcte
    select * from #TEMP
    INSERT INTO #OrderList
    SELECT Row_number() OVER (ORDER BY OrderNo, TableName),
    #TEMP.OrderNo,
    #TEMP.TableName,
    #TEMP.tid,
    #temp.childtable,
    #TEMP.cid
    FROM #TEMP
    SET @Count = (SELECT Max(RecordNo)
    FROM #OrderList)
    select * from #OrderList

    Am looking for a logic to delete the records..Please provide some query to better understand..
    Thats easy, refer the below link: You may check string and then execute if everything looks ok to you.
    Ref:http://social.msdn.microsoft.com/Forums/en-US/bc36c6b6-1aca-43aa-bc95-7518fdb6fe4c/delete-data-from-multiple-tables?forum=transactsql
    declare @Deletecommand varchar(max)
    ;with object_cte(tblid,tblname,rtblid,rtblname,level)
    as
    select distinct o.object_id as tblid,OBJECT_NAME(o.object_id) as tblname,cast(null as int),cast(null as sysname),
    0 as level
    from sys.objects o
    inner join sys.foreign_keys f
    on f.parent_object_id = o.object_id
    where o.is_ms_shipped=0
    and o.type='u' and OBJECT_NAME(o.object_id) like '/BIO/A%'
    union all
    select t.object_id as tblid,OBJECT_NAME(t.object_id) as tblname,o.tblid,o.tblname,o.level + 1
    from object_cte o
    inner join sys.foreign_keys f
    on f.parent_object_id = o.tblid
    join sys.objects t
    on t.object_id = f.referenced_object_id
    where t.is_ms_shipped=0
    and t.type='u'
    and OBJECT_NAME(o.object_id) like '/BIO/A%'
    select @Deletecommand =(select 'DELETE FROM ' + tblname + ';' from
    select row_Number() over (partition by tblname order by level) as rn,* from object_cte
    )t
    where rn=1
    order by level
    for xml path(''))
    print @Deletecommand
    --exec (@Deletecommand)

  • Deadlock when deleting a not linked data record in a parent table

    Hello, who knows about this problem with Oracle 10g:
    Our installation of Oracle 10.2g behaves different from Oracle 9.2 concerning locking of data records:
    To prevent that different users edit a complex data record at the same time and store it, the user has to put
    the data record into the "edit mode" and we lock it with "Select CharFieldZ from TableX where ID = 1 for UPDATE NOWAIT".
    In this data record references (= foreign keys) to other tables are used; with foreign key constraints we
    prevent those data records of these tables from being deleted, which are used in data records of tableX: on
    deleting such a record Oracle gives an error message ORA-02292, which the application translates for the
    user: "You cannot delete this record, because it is used somewhere else".
    Now when locking data record A under Oracle 10.2g, which contains a foreign Key upon data record 1 of tableF,
    and trying to delete data record 2 of tableF, a deadlock appears, even when this data record is not used
    anywhere else.
    Further conditions:
    - Data record 2 was created before locking of data record A.
    - In the same session tableF was opened for reading before.
    Is there a parameter, which leads Oracle 10.2g to return to the former behavoir ?
    or: how is it possible to prevent a deadlock anyhow else ?
    Thanks in advance
    Lothar Weidl-Walther
    Germany
    Edited by: schatzag on 04.02.2009 14:22
    for easier demonstration the SQL-scripts:
    Installation:
    DELETE TableF;
    DELETE TableX;
    CREATE TABLE TableF
    ( ID INTEGER NOT NULL,
    NAME VARCHAR2(30 BYTE) NOT NULL);
    CREATE UNIQUE INDEX PK_TableF ON TableF(ID);
    ALTER TABLE TableF ADD CONSTRAINT PK_TableF PRIMARY KEY(ID);
    INSERT INTO TableF VALUES (1, 'Record1');
    INSERT INTO TableF VALUES (2, 'Record2');
    commit;
    CREATE TABLE TableX
    ( ID INTEGER NOT NULL,
    NAME VARCHAR2(30 BYTE) NOT NULL,
    CharFieldZ VARCHAR2(100 BYTE),
    TableF_ID INTEGER);
    ALTER TABLE TableX ADD (
    CONSTRAINT FK_TableX_TableF
    FOREIGN KEY (TableF_ID)
    REFERENCES TableF (ID));
    INSERT INTO TableX VALUES (1, 'ComplexRecord1', 'User1', 1);
    commit;
    Session1:
    SELECT CharFieldZ FROM TableX WHERE ID = 1 FOR UPDATE NOWAIT;
    SELECT * FROM TableF;
    Session2:
    DELETE FROM TableF WHERE ID = 2;
    Edited by: schatzag on 04.02.2009 14:26

    I'm not aware that the locking mechanism did change between Oracle 9i and 10g. Can you provide a simple and reproducable example?
    You current description is very "uncomplete", e.g. this statement would lock the full table, but I think that is not what your application does.
    Select CharFieldZ from TableX for UPDATE NOWAITAs Peter already mentioned you should check if there are any other differences between the databases. Let me mention just a few points that I can think of at the moment:
    * indexes
    * FK constraints with DELETE CASCADE
    * higher oracle block size (can lead to more ITL locks)
    Edited by: Sven W. on Feb 4, 2009 2:18 PM

  • Deletion from multiple tables

    Hi,
    I am having three tables
    Payment (Parent)
    Header (Child)
    Items (Grand Child)
    one payment can have multiple header and the header can have multiple item in it.
    P
    H H -- level 1
    I I I I -- level 2
    e.g one payment is having 2 headers and each header is having 2 items in it.
    I need to delete the item table first then header table then payment table.
    Condition for deletion. There is field(flag) in item table which decides when to delete record. I need to delete record when all the item records flag value is 2.
    How to check for all items flag value?
    P1
    H1 H2
    I1 I2 I3 I4
    2 1 1 1
    P1
    H1 H2
    I1 I2 I3 I 4
    1 1 2 2
    Since if we miss any check at level 1 or level 2 We will be having Orphan records in the database.
    First case(Level 2 check is missed)then
    I1 -> H1 -> P1 deleted
    and we have H2,I2,I3,I4 Orphans
    Second Case (Level 1 Check is missed)then
    I3,I4 -> H2 -> P1 deleted
    and we have H1,I1,I2 as orphans.
    Please help how to check the flag value of each item. These table are related through primary and foreign keys.
    Thanks in advance
    Edited by: anu2 on Oct 20, 2009 12:04 AM

    Double negation coming up again...
    You can identify the parents that are eligable for deletion as follows:
    select p.*
    from Payment p
    where not exists
          (select 'x'
           from Header h
           where h.FK = p.PK
             and not exists
                  (select 'x'
                   from Items i
                   where i.FK = h.PK
                     and i.status != 2))And then use the resultset of above query to:
    - delete the grandchildren of these parents first,
    - and then delete the children of these parents,
    - and then delete the parents.
    Maybe this helps.
    Edited by: Toon Koppelaars on Oct 20, 2009 9:19 AM

  • On DML operations Locked held on Parent tables.

    Hi All,
    Am trying to delete records from a table such as
    DELETE /*+ index(EVENT_JOURNAL row_ts_idx) */  FROM EVENT_JOURNAL WHERE trunc(ROW_TS)= TO_date('09/05/2012','DD/MM/YYYY');table has function based index on row_ts column
    Plan
    DELETE STATEMENT  ALL_ROWSCost: 138  Bytes: 502 K  Cardinality: 8 K             
        3 DELETE BENCHMARKDEV.EVENT_JOURNAL        
            2 TABLE ACCESS BY INDEX ROWID TABLE BENCHMARKDEV.EVENT_JOURNAL Cost: 138  Bytes: 502 K  Cardinality: 8 K     
                1 INDEX RANGE SCAN INDEX BENCHMARKDEV.ROW_TS_IDX Cost: 23  Cardinality: 8 K  Above delete operation takes much time to delete 273 rows
    I have check that above DML perform getting locked on its parent table. such as
    select    OS_USER_NAME os_user,
        PROCESS os_pid,
        ORACLE_USERNAME oracle_user,
        l.SID oracle_id,
        decode(TYPE,
            'MR', 'Media Recovery',
            'RT', 'Redo Thread',
            'UN', 'User Name',
            'TX', 'Transaction',
            'TM', 'DML',
            'UL', 'PL/SQL User Lock',
            'DX', 'Distributed Xaction',
            'CF', 'Control File',
            'IS', 'Instance State',
            'FS', 'File Set',
            'IR', 'Instance Recovery',
            'ST', 'Disk Space Transaction',
            'TS', 'Temp Segment',
            'IV', 'Library Cache Invalidation',
            'LS', 'Log Start or Switch',
            'RW', 'Row Wait',
            'SQ', 'Sequence Number',
            'TE', 'Extend Table',
            'TT', 'Temp Table', type) lock_type,
        decode(LMODE,
            0, 'None',
            1, 'Null',
            2, 'Row-S (SS)',
            3, 'Row-X (SX)',
            4, 'Share',
            5, 'S/Row-X (SSX)',
            6, 'Exclusive', lmode) lock_held,
        decode(REQUEST,
            0, 'None',
            1, 'Null',
            2, 'Row-S (SS)',
            3, 'Row-X (SX)',
            4, 'Share',
            5, 'S/Row-X (SSX)',
            6, 'Exclusive', request) lock_requested,
        decode(BLOCK,
            0, 'Not Blocking',
            1, 'Blocking',
            2, 'Global', block) status,
        OWNER,
        OBJECT_NAME
    from    v$locked_object lo,
        dba_objects do,
        v$lock l
    where     lo.OBJECT_ID = do.OBJECT_ID
    AND     l.SID = lo.SESSION_ID
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     Transaction     Exclusive     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNIT
    oracle     6624     BENCHMARKDEV     216     DML     Row-X (SX)     None     Not Blocking     BENCHMARKDEV     BUSINESS_UNITI don't know on what basis parent tables are get locked?
    Please help me out to resolve..
    Thanks & Regards
    Sami
    Edited by: Sami on May 16, 2012 3:14 PM
    Edited by: Sami on May 16, 2012 3:15 PM

    Hi Sami,
    Your dont event need Function Based Index on ROW_TS. A normal B*Tree index on ROW_TS will do the trick and also reduce the time for index sorting.
    DELETE FROM EVENT_JOURNAL WHERE ROW_TS >= TO_date('09/05/2012','DD/MM/YYYY') AND ROW_TS < TO_date('10/05/2012','DD/MM/YYYY');
    {code}
    {code}
    Above delete operation takes much time to delete 273 rows
    {code}
    # Is EVENT_JOURNAL parent table and has foreign key references from other tables ?
    # How many records are there in EVENT_JOURNAL ?
    # Check data dictionary view - DBA_WAITERS to see waiting/holding session                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • A recursive deletion?

    Hi All,
    Suppose I have two tables A and B.B is referring to a column in A.so when I delete an entry from table A, is there any way by which all the referred entries in B will also get deleted(instead of showing the referential integrity error)?
    A kind of recursive deletion?
    Thanks in advance,
    JJ

    Then you have (in my opinion) a poor db design. ;)
    Two options spring to mind:
    1. Handle this in your application: Delete all rows from the child table before issuing the delete against the master table.
    2. Create a before delete trigger on the master table in which you delete all rows from the child table that refer to the master.

Maybe you are looking for

  • Apple ID on my computer no longer exists, so I can't sign out

    The Apple ID that is installed on my computer is no longer the email address that I use for my Apple ID, and the email account itself has been deleted so I cannot sign into it to change the settings. My current Apple ID works online on apple.com but

  • How do I move the camera import settings in the list?

    I'd really love to delete all of the LR import presets since I never use them. It's a long list and my camera profiles, which  I do use are always at the bottom. I want them at the top of the list...if I can't delete all of the ones I never use. How

  • 2's comp binary Exponent/Mantissa

    How do I handle a 64 bit word where the exponent is at the beginning of the Binary? I have 4 - 16 bit words that comprise a GPS Time stamp. The format is as follows Binary Format: SEEEEEEEEmmmmmmm....m S: sign E: 8 bit exponent m: 55 bit mantissa Exp

  • Just activated BlueAnt S4 with my iPhone4 and having an issue with the Phone Commands

    Just activated BlueAnt S4 with my iPhone4 and having an issue with the Phone Commands - as I have multiple numbers for people (ie: iPhone, Work, Home), is it the BlueAnt that is having the issues or the iPhone? Tried to eliminate info on my partner's

  • Won't Save Drafts in Mail

    I've seen various problems reported with the Draft mailbox... My problem, very similar to other recent reports-- My drafts disappear (after closing and reopening Mail). My drafts have been faithfully saved for years, until recently ,until 10.5.4. I t