Constraint in Trigger

I had written a trigger as given below. But somehow its not checking the condition i had set in the trigger.
IF Q1 > Q2 THEN RAISE BAD;
Trigger
CREATE OR REPLACE TRIGGER "CM_RECIPE_ITEM_T3"
BEFORE INSERT OR UPDATE
ON "CM_RECIPE_ITEM"
FOR EACH ROW
DECLARE
Q1 NUMBER;
Q2 NUMBER;
BAD EXCEPTION;
BEGIN
SELECT SUM(CRI_QTY)
INTO Q1
FROM CM_RECIPE_ITEM
WHERE CRI_CR_ID = :NEW.CRI_CR_ID;
SELECT CR_QUANTITY
INTO Q2
FROM CM_RECIPE
WHERE CR_ID = :NEW.CRI_CR_ID;
IF INSERTING OR UPDATING
THEN
IF Q1 > Q2
THEN
RAISE BAD;
END IF;
END IF;
EXCEPTION
WHEN BAD
THEN
raise_application_error (-103, 'CRI_QTY exceeding the BOM Qty');
END;
Yogesh

Hi Yogesh,
I think you're logic may be wrong. I assume what you are trying to do is check that the sum of CRI_QTY in the child table does not exceed the maximum CR_QUANTITY as specified in the parent table for a given CR_ID.
I think where you are going wrong is that the trigger is doing the test before the insert or update on the recipe_item so that the trigger never sees the new or changed value. It may see it subsequently where it may then throw up the error, but this will be too late. You should either do the test after insert or update (may cause mutating problems) or you should allow for the new or updated value in the trigger logic.
You should also note that you may run into multi-user concurrency problems with this logic as two users may independently be able to pass the test but collectively may invalidate the logic.
Regards
Andre

Similar Messages

  • ORA-02291 Integrity Constraint exception - 1:1 in BPEL context

    Hi,
    I am using toplink inside a BPEL process (DB adapter).
    I have a table PARTY with PK PARTY_ID and a table BILL_TO_CUSTOMER with PK BILL_TO_CUSTOMER_ID. They can be linked 1:1 using PARTY_ID = BILL_TO_CUSTOMER_ID. It works absolutely fine for update or select operations, but for inserts (using merge) NOT. I get an ORA-02291 error. From the log where I can see the tried SQL command the reason is obvious: He is trying to insert the BILL_TO_CUSTOMER before the PARTY and this does not work as there is a constraint.
    How do I have to change my toplink_mapping XML to get this working?
    Thank you very much, Best Regards,
    Martin
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <opm:name>BillToCustomerParty</opm:name>
    <opm:class-mapping-descriptors>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>BillToCustomerParty.BillToCustomer</opm:class>
    <opm:alias>BillToCustomer</opm:alias>
    <opm:primary-key>
    <opm:field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_PARTY_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="findAllBillToCustomer" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>BillToCustomerParty.BillToCustomer</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
    <opm:attribute-name>contactInformationCollection</opm:attribute-name>
    <opm:reference-class>BillToCustomerParty.ContactInformation</opm:reference-class>
    <opm:private-owned>true</opm:private-owned>
    <opm:target-foreign-key>
    <opm:field-reference>
    <opm:source-field table="CONTACT_INFORMATION" name="PARTY_ID" xsi:type="opm:column"/>
    <opm:target-field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_PARTY_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:target-foreign-key>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:container xsi:type="toplink:container-policy">
    <toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
    </toplink:container>
    <toplink:indirection xsi:type="toplink:transparent-collection-indirection-policy"/>
    <toplink:selection-query xsi:type="toplink:read-all-query">
    <toplink:reference-class>BillToCustomerParty.ContactInformation</toplink:reference-class>
    <toplink:container xsi:type="toplink:container-policy">
    <toplink:collection-type>oracle.toplink.indirection.IndirectList</toplink:collection-type>
    </toplink:container>
    </toplink:selection-query>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>billToCustomerPartyId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_PARTY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>externalBillToCustomerId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="EXTERNAL_BILL_TO_CUSTOMER_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>hashAlgorithmValue</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="HASH_ALGORITHM_VALUE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>lastName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="LAST_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>firstName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="FIRST_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>middleName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="MIDDLE_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>nameSuffix</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="NAME_SUFFIX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>namePrefix</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="NAME_PREFIX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>customerOrganizationName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="CUSTOMER_ORGANIZATION_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressOrganizationName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_ORGANIZATION_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressDepartment</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_DEPARTMENT" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressContactName</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_CONTACT_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressBuilding</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_BUILDING" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressStreet</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_STREET" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressHouseNumber</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_HOUSE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressPoBox</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_PO_BOX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressLocality</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_LOCALITY" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressPostalCode</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_POSTAL_CODE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressProvince</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_PROVINCE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressFormatted</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_FORMATTED" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>genderType</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="GENDER_TYPE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>dateOfBirth</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="DATE_OF_BIRTH" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>clientOrganizationPartyId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="CLIENT_ORGANIZATION_PARTY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>phoneNumber</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="PHONE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>faxNumber</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="FAX_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>mobileNumber</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="MOBILE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>emailAddress</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="EMAIL_ADDRESS" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>lastUpdated</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="LAST_UPDATED" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressCountryId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="ADDRESS_COUNTRY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>currentContactInformationId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER" name="CURRENT_CONTACT_INFORMATION_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>billToCustomerGroup</opm:attribute-name>
    <opm:reference-class>BillToCustomerParty.BillToCustomerGroup</opm:reference-class>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_GROUP_ID" xsi:type="opm:column"/>
    <opm:target-field table="BILL_TO_CUSTOMER_GROUP" name="BILL_TO_CUSTOMER_GROUP_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_GROUP_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:selection-query xsi:type="toplink:read-object-query">
    <toplink:reference-class>BillToCustomerParty.BillToCustomerGroup</toplink:reference-class>
    </toplink:selection-query>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="BILL_TO_CUSTOMER"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>BillToCustomerParty.BillToCustomerGroup</opm:class>
    <opm:alias>BillToCustomerGroup</opm:alias>
    <opm:primary-key>
    <opm:field table="BILL_TO_CUSTOMER_GROUP" name="BILL_TO_CUSTOMER_GROUP_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="findAllBillToCustomerGroup" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>BillToCustomerParty.BillToCustomerGroup</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>billToCustomerGroupId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER_GROUP" name="BILL_TO_CUSTOMER_GROUP_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>clientOrganizationPartyId</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER_GROUP" name="CLIENT_ORGANIZATION_PARTY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>description</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER_GROUP" name="DESCRIPTION" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>code</opm:attribute-name>
    <opm:field table="BILL_TO_CUSTOMER_GROUP" name="CODE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="BILL_TO_CUSTOMER_GROUP"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>BillToCustomerParty.ContactInformation</opm:class>
    <opm:alias>ContactInformation</opm:alias>
    <opm:primary-key>
    <opm:field table="CONTACT_INFORMATION" name="CONTACT_INFORMATION_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="findAllContactInformation" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>BillToCustomerParty.ContactInformation</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>hashAlgorithmValue</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="HASH_ALGORITHM_VALUE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>lastName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="LAST_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>firstName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="FIRST_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>middleName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="MIDDLE_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>nameSuffix</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="NAME_SUFFIX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>namePrefix</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="NAME_PREFIX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>organizationName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ORGANIZATION_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressOrganizationName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_ORGANIZATION_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressDepartment</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_DEPARTMENT" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressContactName</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_CONTACT_NAME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressBuilding</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_BUILDING" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressStreet</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_STREET" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressHouseNumber</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_HOUSE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressPoBox</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_PO_BOX" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressLocality</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_LOCALITY" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressPostalCode</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_POSTAL_CODE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressProvince</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_PROVINCE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressFormatted</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_FORMATTED" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>contactInformationId</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="CONTACT_INFORMATION_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>datetimeReceived</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="DATETIME_RECEIVED" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>dateOfBirth</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="DATE_OF_BIRTH" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>genderType</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="GENDER_TYPE" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>phoneNumber</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="PHONE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>faxNumber</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="FAX_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>mobileNumber</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="MOBILE_NUMBER" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>emailAddress</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="EMAIL_ADDRESS" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>addressCountryId</opm:attribute-name>
    <opm:field table="CONTACT_INFORMATION" name="ADDRESS_COUNTRY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="CONTACT_INFORMATION"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>BillToCustomerParty.Party</opm:class>
    <opm:alias>Party</opm:alias>
    <opm:primary-key>
    <opm:field table="PARTY" name="PARTY_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="BillToCustomerPartySelect" xsi:type="toplink:read-all-query">
    <opm:criteria operator="and" xsi:type="toplink:logic-expression">
    <toplink:left operator="equal" xsi:type="toplink:relation-expression">
    <toplink:left name="clientOrganizationPartyId" xsi:type="toplink:query-key-expression">
    <toplink:base name="billToCustomer" xsi:type="toplink:query-key-expression">
    <toplink:base xsi:type="toplink:base-expression"/>
    </toplink:base>
    </toplink:left>
    <toplink:right xsi:type="toplink:parameter-expression">
    <toplink:parameter name="clientOrganizationId" xsi:type="opm:column"/>
    </toplink:right>
    </toplink:left>
    <toplink:right operator="equal" xsi:type="toplink:relation-expression">
    <toplink:left name="externalBillToCustomerId" xsi:type="toplink:query-key-expression">
    <toplink:base name="billToCustomer" xsi:type="toplink:query-key-expression">
    <toplink:base xsi:type="toplink:base-expression"/>
    </toplink:base>
    </toplink:left>
    <toplink:right xsi:type="toplink:parameter-expression">
    <toplink:parameter name="externalBillToCustomerId" xsi:type="opm:column"/>
    </toplink:right>
    </toplink:right>
    </opm:criteria>
    <opm:arguments>
    <opm:argument name="externalBillToCustomerId">
    <opm:type>java.lang.String</opm:type>
    </opm:argument>
    <opm:argument name="clientOrganizationId">
    <opm:type>java.lang.Integer</opm:type>
    </opm:argument>
    </opm:arguments>
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>BillToCustomerParty.Party</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    <opm:query name="findAllParty" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>BillToCustomerParty.Party</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>billToCustomer</opm:attribute-name>
    <opm:reference-class>BillToCustomerParty.BillToCustomer</opm:reference-class>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="PARTY" name="PARTY_ID" xsi:type="opm:column"/>
    <opm:target-field table="BILL_TO_CUSTOMER" name="BILL_TO_CUSTOMER_PARTY_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="PARTY" name="PARTY_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:indirection xsi:type="toplink:value-holder-indirection-policy"/>
    <toplink:selection-query xsi:type="toplink:read-object-query">
    <toplink:reference-class>BillToCustomerParty.BillToCustomer</toplink:reference-class>
    </toplink:selection-query>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>partyId</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="PARTY" name="PARTY_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>partyTypeId</opm:attribute-name>
    <opm:field table="PARTY" name="PARTY_TYPE_ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.Integer</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>activeInd</opm:attribute-name>
    <opm:field table="PARTY" name="ACTIVE_IND" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>createdDatetime</opm:attribute-name>
    <opm:field table="PARTY" name="CREATED_DATETIME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="PARTY"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    </opm:class-mapping-descriptors>
    </toplink:object-persistence>

    I am replying to very old reported problem, since i struggled to get the right reason for this error.
    In my database we had database constraint & associated trigger, On Insert the trigger gets Sequence. NextVal and inserts into PK column. This constraint trigger gets conflict with the Oracle Native Sequence Generator. I disabled the trigger and used my ESB native sequence (which also does sequence.nextVal) and it worked perfectly.
    If the trigger is Must then make sure that there is If condition wherein it checks to set NextVal only if no input has been provided for PK. If input contains PK value then trigger should do nothing.

  • Difference between before and after trigger

        Is there any difference between these two trigger  .
        If its there , then please tell when we should use before trigger and after trigger
       thanx
       young bro
       

    BEFORE Triggers
    BEFORE triggers run the trigger action before the triggering statement is run. This type of trigger is commonly used in the following situations:
    When the trigger action determines whether the triggering statement should be allowed to complete. Using a BEFORE trigger for this purpose, you can eliminate unnecessary processing of the triggering statement and its eventual rollback in cases where an exception is raised in the trigger action.
    To derive specific column values before completing a triggering INSERT or UPDATE statement.
    AFTER Triggers
    AFTER triggers run the trigger action after the triggering statement is run.
    Trigger Type Combinations
    Using the options listed previously, you can create four types of row and statement triggers:
    BEFORE statement trigger
    Before executing the triggering statement, the trigger action is run.
    BEFORE row trigger
    Before modifying each row affected by the triggering statement and before checking appropriate integrity constraints, the trigger action is run, if the trigger restriction was not violated.
    AFTER statement trigger
    After executing the triggering statement and applying any deferred integrity constraints, the trigger action is run.
    AFTER row trigger
    After modifying each row affected by the triggering statement and possibly applying appropriate integrity constraints, the trigger action is run for the current row provided the trigger restriction was not violated. Unlike BEFORE row triggers, AFTER row triggers lock rows.
    You can have multiple triggers of the same type for the same statement for any given table. For example, you can have two BEFORE statement triggers for UPDATE statements on the employees table. Multiple triggers of the same type permit modular installation of applications that have triggers on the same tables. Also, Oracle materialized view logs use AFTER row triggers, so you can design your own AFTER row trigger in addition to the Oracle-defined AFTER row trigger.
    You can create as many triggers of the preceding different types as you need for each type of DML statement, (INSERT, UPDATE, or DELETE).
    S

  • Blocking sessions during MGP compose

    We keep getting the MGP compose process blocked by inactive sessions
    We raised a SR with Oracle and they suggested adding the instance parameter DO_APPLY_BFR_COMPOSE=YES to webtogo.ora, but this does not seem to have cured the problem.
    From tracing, it seems that the problem is an inactive apply session that resulted in an error, being there for the user it is trying to compose. The actual block is on the table MOBILEADMIN.C$ALL_CLIENT_ITEMS.
    If an apply fails due to an error (eg: constraint violarion, trigger failure etc), it executes the statement
    UPDATE MOBILEADMIN.C$ALL_CLIENT_ITEMS SET CRR='Y' WHERE CLIENTID=? AND PUBLICATION_ITEM IN ( SELECT PUBLICATION FROM MOBILEADMIN.C$ALL_TEMPLATE_ITEMS ati WHERE ati.TEMPLATE=?):
    as part of the copy to the error queue. It also looks to execute the same statement at the beginning of the compose for the user, hence the block.
    The other odd thing is that looking at the blocks this morning, the MGP apply/compose kicked off at 7.09 am. The user synchronised at just after 8 am, by which time the MGP cycle was well into the compose phase, and there is no record of apply activity for the user within the cycle (the actual apply is in the following cycle), the the content of the blocking session was definitely apply code.
    MGP used to do all of the applys first, and then all of the composes, with a test to skip the compose if there was data in the user in queue. The upgrade to 10.2 (or one of the many patches since) looks to have changed the default behaviour to attempt an apply before each user compose, but the parameter above was supposed to set the server back to its old behaviour (ie: keep apply and compose seperate). NOTE i have not seen any of the old 'compose deferred because of unprocessed data in the in queue' messages in the compose recently either.
    Upshot is that it looks like it is still mixing apply and compose together, and where the apply hits an error, the apply thread is not closing correctly, or releasing its locks.
    Does anyone have any information about the parameters
    DO_APPLY_BFR_COMPOSE or
    SKIP_INQ_CHK_BFR_COMPOSE (this appeared with a value of NO when we added the other parameter.
    Information from oracle is that the two are mutualy exclusive (?) but they are not documented anywhere that i can find (the one reference on metalink leads to a non existant note), and oracle seem reluctant to supply any
    so PLEASE
    a) any information about the parameters
    b) any dependancies (ie: parameters not working because we are missing a patch)
    c) location of documentation
    d) any other ideas

    which version are you on?
    we are on 10.2.0.2, so unsure if this works in other versions
    The standard mobile manager parameters screen does not by default show these settings, but we were asked to add them into the webtogo.ora file in the [CONSOLIDATOR] section eg:
    [CONSOLIDATOR]
    # Installer will change these values
    SERVER_VERSION=8.1.7
    SKIP_INQ_CHK_BFR_COMPOSE=YES
    DO_APPLY_BFR_COMPOSE=NO
    RESUME_FILE_SIZE=512
    # 8.1.7
    # Installer won't change these values
    MAX_THREADS=3
    JDBC_DRIVER=oracle.jdbc.driver.OracleDriver
    once this was done we stopped and restarted the mobile server and then the new parameters will appear in the normal data synchronisation>administration>instance parameters screen
    our current setting on the live system are
    SKIP_INQ_CHK_BFR_COMPOSE YES
    DO_APPLY_BFR_COMPOSE NO
    and this does the compose whether or not there is pending data in the in queues for the client. Just my opinion, but there seems little point in doing the check as even if you force two tries of the apply process (one in the main apply phhase before the compose phase, and one just before composing for a particular user), the data in the second apply will not be picked up on fast refresh publication items as the 'snapshot' of the changes has already been done in the process logs phase

  • Slightly off topic: Read-only tables pre 11g

    Hi gang
    I'm just writing up a database quiz for a local user group and I was hoping I could get a bit of inspiration from the database experts.
    One of the questions will be "prior to 11g with the introduction of read-only tables, how could you make a table read-only?". The answers I've come up with:
    1) Security priviliges (schema + grant SELECT)
    2) Triggers
    3) Create a check constraint with disable validate
    4) Read-only tablespace
    5) Read-only database (standby)
    6) (Slightly crazy) Create view, and instead-of triggers that do nothing (similar to 2)
    7) Write the query results on a piece of paper and then turn the database off
    Anybody have any other answers, real or slightly off topic like mine please? ;)
    Cheers,
    CM.

    Check constraint and trigger solutions may have problems with sqlldr direct path operations, so using it together with alter table disable lock may be mandatory depending on the needs. Especially if DDLs are also wanted to be avoided.
    This topic was once mentioned on Tom Kyte's blog or asktom but I couldn't find the source to link here.
    SQL> conn hr/hr
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as hr
    -- cleaning objects
    SQL> drop table tong purge ;
    Table dropped
    SQL> drop view vw_tong ;
    View dropped
    -- creating the demo table
    SQL> create table tong ( col1 number ) ;
    Table created
    SQL> alter table tong add constraint cc_tong check ( 1=0 ) disable validate;
    Table altered
    SQL> alter table tong disable table lock;
    Table altered
    -- some DDL tests
    SQL> drop table tong ;
    drop table tong
    ORA-00069: cannot acquire lock -- table locks disabled for TONG
    SQL> truncate table tong ;
    truncate table tong
    ORA-25128: No insert/update/delete on table with constraint (HR.CC_TONG) disabled and validated
    SQL> alter table tong parallel ;
    alter table tong parallel
    ORA-00069: cannot acquire lock -- table locks disabled for TONG
    SQL> lock table tong in exclusive mode ;
    lock table tong in exclusive mode
    ORA-00069: cannot acquire lock -- table locks disabled for TONG
    -- some DML tests
    SQL> select * from tong ;
          COL1
    SQL> update tong set col1 = col1 + 1 ;
    update tong set col1 = col1 + 1
    ORA-25128: No insert/update/delete on table with constraint (HR.CC_TONG) disabled and validated
    -- creating dependent objects test
    SQL> create index nui_tong on tong(col1) nologging ;
    Index created
    SQL> create view vw_tong as select * from tong ;
    View created
    added comments to the code
    Message was edited by:
    TongucY

  • No progress seen in OATM migration

    Hi Gurus,
    I am performing OATM migration on my 11.5.10.2 applications with 10.2.0.4 database.
    I see the status is 99.96% completed -
    Generating Migration progress report for all schemas. Please wait...
    Migration Progress Report
    Report Date : April 13, 2011 PA
    GE: 1
    Total No. Commands Commands % completion
    of commands in error in success of migration
    118,161 28 118,112 99.96%
    SQL> select count (*) from fnd_ts_mig_cmds where MIGRATION_STATUS='GENERATED';
    COUNT(*)
    5067
    I see there are still 5067 commands with GENERATED status and which are yet to be executed. I have been waiting for almost a day and this 5067 count never reduces further.
    I even tried to restart the queue TBLMIG_MESSAGEQUE and bounced DB, then restarted OATM utility.. no luck though.
    Can some one help me on this please ?
    Thanks,
    Khan

    Hi Helios,
    The issue was fixed.
    All the left over commands in GENERATED status were to Enable constraint, policy, trigger, queues, etc.
    I executed the post migration script to to Enable constraint, policy, trigger, queues, etc which brought the count down.
    Thanks for the response Helios.
    Regards,
    Khan.

  • Error importing data via Apex

    Hi,
    I have an apex application on a 10g XE machine, and am in the process of migrating
    this to an 11g machine (same version of apex: 3.2.1).
    With a dozen or more "Apex" users, I first was a little disgruntled to find that there wasn't
    a readily-available tool to migrate all the users across (add that to the "wish list" presuming there
    isn't an easy user-migration mechanism, please).
    Then I took the DDL across to the new platform, which worked quite well.
    My next task was to move the data, in prior preparation for moving the applications.
    On the old machine I performed a "data unload" to a separate XML file on each of my three tables
    (its not a huge application).
    On the new machine, I tried a "data load" into one table, and all I got was the unimaginative
    error message shown below:
    ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00222: error received from SAX callback function ORA-01008: not all variables bound ORA-24801: illegal parameter value in OCI lob function ORA-24801: illegal parameter value in OCI lob function
    Of course, all these error messages are really informative... I can work out (not) from the error message
    how to solve the problem... !
    The table I'm moving has a dozen rows in it. The table has two CLOB columns in it and two BLOB columns.
    If I cannot easily migrate the data, there's no point in moving the applications. Time to ask the forum for
    help please.
    Various attempts of backing up the whole schema with "exp" and "expdp" and even "SQL Developer" proved futile, now
    it looks that I can add "apex" to that list too.
    Any help appreciated; thanks in advance.
    Mungo

    Thankyou for your kind reply.
    flavioc wrote:
    First of all, apex users are migrated when you export and import the workspace.I'm guessing you have to be the Apex Administrator to do that? On my hosted source
    application the highest privilege I enjoy is a single Workspace Administrator - nothing higher.
    Hence the need to transfer the data "the long way".
    >
    Secondly, in my own experience XML data exports are good for simple cases, reasonable amount data (less than 100.000 rows) otherwise you may incur in a variety of problems like insufficient memory, table loading order because of failing constraints and trigger based rules.The XML file I am attempting to import is 928Kbytes in size, and comprises about twelve records with photographs stored in BLOBs
    to bulk out this file.
    >
    Thirdly, i do not see why exp or expdp should not work, i'm using them all the time, so may be you want to be more specific on this.
    As I understand it "expdp" needs a Directory object... that would require raising a ticket with the hosting company and asking for
    them to create one (a step too far, at the moment ;-)
    From failing human memory, the "exp" command seemed to store the tablespace where the tables were stored in. When I then went to
    import from the resultant exported file, the tablespaces were different on the new machine. So I gave up on "exp".
    I thought that the relatively new "SQL Developer" would come to my rescue, but it also has problems with CLOB and BLOB columns.
    All in all it seems to be more work than I had bargained for: all I want to do is "lift" the application off one machine and drop it on
    to the new machine, but Oracle seems to want me to spend at least three days to workaround all the silly "features".
    Comments borne on frustration; forgiveness requested...
    Mungo :-)

  • Modelling Time Slots in a Database

    I need to create a database that has the following requirements:
    1. Locations need to have customizable timeslots, to which actions can be assigned.
    2. Timeslots are 30 minute intervals
    3. Multiple actions can be assigned to single timeslots
    I have thought of the following design, but I am unsure if this is the best way to do this. It seems this method would give a lot of redundancy.
    In this scheme, everything in caps is a table, * means many, 1 means 1, --- stands for a relationship.
    "ACTION" \*---* "TIME_SLOT" ---1 "DAY" ---1 "LOCATION"
    Example: A location may have the following timeslots: 25-08-12 8:00-20:00, 26-08-12 10:00-20:00, 28-08-2012 10:00-12:00, 28-08-2012 12:30-20:00
    Using my design, this example would:
    - give 3 records in DAY for this location.
    - give 24 records in TIME_SLOT for the first day
    - give 20 records in TIME_SLOT for the second day
    - give 19 records in TIME_SLOT for the third day

    >
    Paulie wrote
    >
    See my post - one of the ideas I proposed - as it happens our posts overlapped.
    >
    Not sure what post you are referring to. I don't see ANY post that mentions 48 'columns' in
    a table. And the only posts of yours that mention '48' come after mineWe appear to be in different time zones - I meant that our posts overlapped temporally (and conceptually)
    After my first post on the 12th, I then went on to propose a Slot table (with the possibility of putting all the slots
    for a 24 hour period in the table) - when I posted and refreshed the thread, your post was there - we seemed
    to have the same idea at the same time - great minds &c. ;)
    1. May 10, 2012 5:44 pm - If timeslots are 30 minutes long then there should be 48 per day.I missed that - or maybe thought that it was just a logical statement, rather than a suggestion of
    what should/could be done - there probably should be 48 unless the OP can absolutely
    guarantee that there will never be any slots outside the 08:00 - 20:00 window.
    In response to my '2. Use Y/N to indicate if the slot is being used.' you ask
    >
    What is/are the advantage(s)/disadvantage(s) over using a CHECK constraint as I said?
    >
    A CHECK constraint is a good suggestion. It is easily implemented and understand and self-checking; an exception will be raised if it is violated.All part of the service...
    My comments are trying to suggest alternative funtionality: 1) 48 different columns in one row
    with a flag to indicate if the column is being used,Do you mean something like ?
    CREATE TABLE Slot
      Slot1  Number(2, 1)
      Slot1_Desc  VARCHAR2(50)
      Slot1_Used Boolean
      Slot2
      Slot2_Desc
      Slot48
      Slot48_Desc
    );A simplistic interpretation of Normalisation is that tables should
    be tall and skinny (a bit like women ;) ) and not short and fat.
    I would be very reticent to go down this road - if I've understood you correctly.
    2) one varchar2(48) column that is just all 48 flags concatenated
    together and 3) a separate 48 record lookup table for the timeslots.Could you provide CREATE TABLE defintions? I'm not sure that I'm grasping what you're getting at.
    For #3 you would use a foreign key constraint but for the other two whether you need a
    constraint or not depends on the business rule you want to implement.Definitions please - it's easier to visualise the solution with those.
    A boolean flag can be implemented in a variety of ways. One way is to assign one value for TRUE
    and allow anything else to be considered FALSE (or vice versa). That implements the needed flag
    without a constraint and without needing to handle an exception.Yep - got that bit.
    In many cases it is a decision about where the organization wants to implement the business rules: in
    the database (constraint or trigger) or somewhere in the application code.The longer I'm in this game, the closer I think that any and all logic should be to the database.
    Check out Billy's contribution here: Re: Install Questions
    and anything by Toons Kopellar.
    You said
    >
    Here I disagree - I think that the timeslot concept is central - as indeed are all of the tables I suggested. The whole
    I think that the timeslot concept is central - as indeed are all of the tables I suggested. The whole
    point about prototyping is that IMHO every table is important because initially every table has a large effect on
    every other table and also, in the event of an upgrade/redesign, the already existing tables are critical - unless
    one decides to completely bin the old design - not often an option in the real world unfortunately.
    >
    Well that is what design discussions are all about - presenting alternative ways of looking at things.Yep - again.
    My point is that, as can be seen clearly by the actual table examples you have provided (thank you
    for that), is that it is really fairly straightforward to create sample tables and prototypes to experiment
    with and see how well they seem to match the requirements. In my experience far too many projects
    don't do enough of this.Amen to that.
    Considerations for upgrades and redesigns should primarily be considered when the development
    team is selecting the final architecture after considering ALL of the viable alternatives.Again, agreed, but post your table definitons. There are some solutions which can be eliminated staight away.
    The stage for the current thread is architecture and design. So IMHO it is appropriate to consider
    several alternative implementations and create a prototype for each.Agreed yet again.
    It is rather trivial to create some INSERT scripts to insert data into the tables you suggested and to
    perform some simple update queries and select queries to mimic actual use.That would be the idea - as I think I mentioned in one of my posts to this thread, the OP should be prepared
    for plenty of "Doh" moments.
    As you indicate the final selection of architecture and implementation will constrain the ability to maintain
    the application and add enhancements. That makes it even more important not to cut short the prototype
    and analysis phase where alternative designs are considered.Boss: "You start coding, I'll give you the requirements later". I've come pretty close (real life) Boss: "We need a
    flight pay system", me: "Ah..." - very much a requirements evolving as coding did - an extreme example of
    the iterative model in action.
    <balancing TOP-DOWN/BOTTOM-UP approaches snipped - agreed>
    Those projects used an iterative process that would result in the least restrictive model that met the requirements.
    So I think we are in basic agreement.Indeed, as to the general thrust as to how, ideally, one should design an app, yes.
    As OP stated
    >
    3. Multiple actions can be assigned to single timeslots
    >
    keeing multiple timeslot indicators in a single record is not applicable for that use case. I was just
    trying to illustrate, as you were also, that you need to jot down potential solutions when you think
    of them and even do prototype implementations to see how they work.See my "Ooops" post - put multiple Actions into a Project and assign that "Project" a timeslot.
    Paul...

  • Oracle table limitation

    with regard to oracle limiting 1000 column per table I did split the table into two tables but I want to create a view that join the two tables but the view also is limited to 1000 columns , so I have to change all the SQL statements that referenced that table to the new join statement but if I can resolve this having not to change the SQL would help me a lot.. ANY IDEAS.

    You have a limitation with table name, constraint name, trigger name, ...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Liu qing ([email protected]):
    hi
    oracle up limitation ?
    <HR></BLOCKQUOTE>
    null

  • Oracle 10g HTMLDB,.. How to EDIT TABLEs

    Hi,
    I am new to DBs. I am doing a class project on Oracle 10g HTML DB. I have created the ER Diagram but am having problems implementing it in Oracle.
    Here are the problems:
    1) Editing tables
    Currently I am using the wizard the make the tables:
    Workspace AMANSOOR>SQL Workshop>Create Table
    Now the table is created, the primary key is set, but then lets say that
    a) I have to go back and edit the table, perhaps add a cloumn etc, how do i do that.
    b) More over if I have to add a new CONSTRAINT, or TRIGGER, where do i do that,..
    I would really appreciate any help,..
    Thank you,..

    Never mind,.. i got the answer,..

  • Partitioning (range) a table values less than 'A'

    i am referring
    http://docs.oracle.com/cd/B10501_01/server.920/a96524/c12parti.htm
    http://docs.oracle.com/cd/B19306_01/server.102/b14220/partconc.htm
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    create table drop_it as select * from mv_prod_search_det2;     
    CREATE TABLE DROP_IT_P(
    PROD_DETAILS VARCHAR2(1000 BYTE),
         SIGN VARCHAR2(42 BYTE)
    PARTITION BY RANGE(PROD_DETAILS)
    PARTITION MAX_VALUE VALUES LESS THAN (MAXVALUE)
    update drop_it set prod_details=upper(prod_details);     
    72000 rows updated
    ALTER TABLE drop_it_p EXCHANGE PARTITION MAX_VALUE WITH TABLE drop_it WITH VALIDATION;     
    select * from mv_prod_search_det2
    72000 rows selected
    exec dbms_stats.gather_database_stats;
    select * from drop_it_p partition(max_value)
    ALTER TABLE DROP_IT_P
      SPLIT PARTITION MAX_VALUE AT ('B%')
      INTO (PARTITION p_a,
            PARTITION MAX_VALUE);     
    select * from drop_it_p partition(p_a);
    6785 rows selected
    select * from drop_it_p partition(p_a) where prod_details not like 'A%'     
    696 rows selectedit even shows me values that start with W,V,I,1,2,3,4,24,5 etc
    although the number is less(696out of 6785) this is undesired
    please help me eliminate these rows
    thank you
    this thread is related to tuning regexp_like by author 946207
    please refer
    tuning regexp_like
    and partitioning a table by 946207
    Edited by: 946207 on Dec 2, 2012 1:52 AM
    Edited by: 946207 on Dec 2, 2012 11:02 PM

    First, when you post related threads you should cross-link them so people have access to all of the information about the problem you are trying to work with.
    partitioning a table
    >
    it even shows me values that start with W,V,I,1,2,3,4,24,5 etc
    although the number is less(696out of 6785) this is undesired
    >
    Yes - that is what it should be doing.
    These are the steps you took to populate the table
    1. You originally inserted ALL data into table 'drop_it' with no restriction on the PROD_DETAILS values.
    create table drop_it as select * from mv_prod_search_det2;     2. Then you converted the PROD_DETAILS value to upper case. That has no effect on numbers or other non-alphabetic characters.
    update drop_it set prod_details=upper(prod_details);3. Then you create a new table with only one partition using MAXVALUe
    PROD_DETAILS VARCHAR2(1000 BYTE),
         SIGN VARCHAR2(42 BYTE)
    PARTITION BY RANGE(PROD_DETAILS)
    PARTITION MAX_VALUE VALUES LESS THAN (MAXVALUE)
    );4. Then you populate the partitioned table by exchange. It now has the same data including the numeric data.
    ALTER TABLE drop_it_p EXCHANGE PARTITION MAX_VALUE WITH TABLE drop_it WITH VALIDATION;     5. Then you split the one MAXVALUE partition into two partitions. One with data < 'B%' and one with the remaining data that sorts higher based on your character set.
    ALTER TABLE DROP_IT_P
      SPLIT PARTITION MAX_VALUE AT ('B%')
      INTO (PARTITION p_a,
            PARTITION MAX_VALUE);     The split on 'B%' when creating partition p_a is equivalent to you 'WITH VALUES < 'B%'. Since PROD_DETAILS is a VARCHAR2 datatype that 'LESS THAN' comparison uses the character order based on your database character set and most, if not all, character sets have characters that sort lower than the uppercase alphabetic characters.
    For example in the ASCII character set an uppercase 'A' is decimal 65 so 64 other characters (including the digitis 0-9) sort lower than 'A'.
    http://www.asciitable.com/
    As the doc you cited shows
    >
    •All partitions, except the first, have an implicit lower bound specified by the VALUES LESS THAN clause on the previous partition.
    >
    That 'first' partition has no lower bound so ALL data, including digits, that sort less than 'B%' will be in that partition.
    >
    please help me eliminate these rows
    >
    Either don't select the data to begin with or remove it using a simple DELETE query. Also you can do the case conversion when you select the data.
    create table drop_it as select upper(prod_details) prod_details, sign from mv_prod_search_det2 where upper(prod_details >= 'A';Before you do that you should make sure you define the actual business rule you want to use to define the data you really want to keep and exclude.
    Because most, if not all, character sets also have characters that sort HIGHER than the alphabetic characters. That ASCII table shows five of them. If you don't filter them out you will get data where the values start with those characters.
    Even if you do filter them out there is nothing in what you posted that would prevent a user from inserting that data back into the table.
    And, of course, there are characters that sort BETWEEN the lower and upper case alphabetics.
    You need to determine what the allowable characters are in the PROD_DETAILS column and add code (e.g. check constraint or trigger) to make sure users can't enter data that includes those characters.

  • Identifier too long

    hi
    oracle up limitation ?
    create table aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(a char);
    Error
    ORA-00972:identifier too long
    or
    create table a (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa char);
    Error
    ORA-00972:identifier too long
    Oracle can not support upto 32 characters table name and field name ?
    It is true?
    null

    You have a limitation with table name, constraint name, trigger name, ...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Liu qing ([email protected]):
    hi
    oracle up limitation ?
    <HR></BLOCKQUOTE>
    null

  • Differences between trigger and Integrity Constraints

    waht are the differences between trigger and Integrity Constraints

    waht are the differences between trigger and Integrity ConstraintsConstraints are to be preferred:
    "Declarative Ease
    Define integrity constraints using SQL statements. When you define or alter a table, no additional programming is required. The SQL statements are easy to write and eliminate programming errors. Oracle controls their functionality. For these reasons, declarative integrity constraints are preferable to application code and database triggers. The declarative approach is also better than using stored procedures, because the stored procedure solution to data integrity controls data access, but integrity constraints do not eliminate the flexibility of ad hoc data access.
    Centralized Rules
    Integrity constraints are defined for tables (not an application) and are stored in the data dictionary. Any data entered by any application must adhere to the same integrity constraints associated with the table. By moving business rules from application code to centralized integrity constraints, the tables of a database are guaranteed to contain valid data, no matter which database application manipulates the information. Stored procedures cannot provide the same advantage of centralized rules stored with a table. Database triggers can provide this benefit, but the complexity of implementation is far greater than the declarative approach used for integrity constraints."
    More:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/data_int.htm#sthref2976

  • What are the differences between trigger and constraints?

    what are the differences between trigger and constraints?

    Try the documentation, this would be a good starting point: How Oracle Enforces Data Integrity
    C.

  • Constraint Checking Vs After Row Trigger

    According to db concepts Chap 17 Trigger -> Trigger Execution, integrity checking is performed BEFORE the after row trigger executed. I guess this is not 100% true. AFAIK, we can create an AFTER ROW trigger on a child table which automatically insert new referenced row in the parent table. e.g.
    CREATE TABLE child (
    child_id int primary key,
    parent_id int references parent,
    CREATE TABLE parent (
    parent_id int primary key,
    CREATE OR REPLACE TRIGGER A
    AFTER INSERT OR UPDATE on child
    FOR EACH ROW
    BEGIN
    INSERT INTO parent values (:new.parent_id,...);
    END;
    If the constraint checking is done before the trigger, the referential integrity should have been violated when the child row is inserted.
    So if the documentation is wrong, when will the constraint checking be carried out with respect to trigger execution.

    There are plenty of things that are easier and/or safer to do in an AFTER ROW trigger, since can see exactly what the data in the row has been set to by any BEFORE ROW triggers and you can't change the data inadvertently. If your BEFORE ROW triggers are calling relatively complex procedures owned by various disparate groups of developers, it can be non-trivial to ensure that every groups changes are perfectly coordinated. AFTER ROW triggers are a heck of a lot easier to deal with here because you don't have to worry about another section of code changing the data you're using to make your decision.
    I'm hard pressed to think of something that couldn't possibly be accomplished in a BEfORE ROW trigger, though I suspect there are at least a few oddball situations.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • Mac Lion Server Error 24 Installing Elements 10 DVD or Trial Download

    Error Package Support Uploaded: 00-30402-091818122011 xit Code: 24 -------------------------------------- Summary -------------------------------------- - 0 fatal error(s), 18 error(s), 0 warning(s) ERROR: DW001: Set payload cancelled status ERROR: D

  • Can't view a movie I purchased from iTunes

    I have purchased Harold and Kumar escape from Guantanamo Bay from the iTunes store. The first time I bought it via the apple TV menu and tried watching it after it finished downloading. All I got was a white screen, no sound, no video but it did have

  • Problem in loading an external file with unicode name

    Hi, I am working on a project which involves loading of an external file with unicode name for ex: "插入音乐.mp3 ,插入音乐.jpg". These unicode files are loaded successfully when I play/publish the movie with flash player alone. But when the movie is embedded

  • Asynchrnous Update for the report?

    I know there is Asynchrnous Update for the chart in HTMLDB - if you enable it, and if the underlying data has changed, when the next update interval passed, you will see the chart updated with the new data. Does this feature also apply to tabular tab

  • Username and password problems with CS3

    I have Dreamweaver CS3 Version 9.0 Build 3481 When I close Dreamweaver and reopen it I lose any usernames and passwords for FTP. How do I solve this? The 8.0.2. Updater does not work for my version. Thank you