How to cascade update

how to cascade update?

Sorry everyone for going regional with my Mexican fiend!
In MEXMAN's first case, integrity on related data was already being enforced through a valid foreign key (TIZAYUCA.REGLAFAB_PRODUCTO_FK). However, the user wanted to update data included in the foreign key relationship. To acomplish this, I recommended to change the actual constraint state to defer validation until commit. Using the now familiar column names, the sentences are:
ALTER TABLE TIZAYUCA.REGLA_FABRICACION
DROP CONSTRAINT REGLAFAB_PRODUCTO_FK;
ALTER TABLE TIZAYUCA.REGLA_FABRICACION
ADD CONSTRAINT REGLAFAB_PRODUCTO_FK FOREIGN KEY (GRUPO, PRODUCTO)
REFERENCES TIZAYUCA.PRODUCTO (GRUPO, CLAVE)
INITIALLY DEFERRED;
In MEXMAN's second case, a wholly new integrity needs to be enforced between two tables but some actual data present in both tables do not validate the desired constraint. The offending rows from the child table (TIZAYUCA.PRESENTACION) may be obtained executing
SELECT *
FROM tizayuca.presentacion t
WHERE (t.grupo, t.producto) NOT IN
(SELECT p.grupo, p.clave
FROM tizayuca.producto p);
MEXMAN has 3 choices:
1. deleting the offending rows in the child table (TIZAYUCA.PRESENTACION) before executing
alter table TIZAYUCA.PRESENTACION enable constraint PRES_PROD_FK;
2. inserting the missing rows in the parent table (TIZAYUCA.PRODUCTO) before executing
alter table TIZAYUCA.PRESENTACION enable constraint PRES_PROD_FK;
3. making the new constraint ignore the present data and enforcing the relationship starting with new data:
alter table TIZAYUCA.PRESENTACION
add constraint PRES_PROD_FK foreign key (GRUPO, PRODUCTO)
references TIZAYUCA.PRODUCTO (GRUPO, CLAVE)
deferrable initially deferred
enable novalidate;
(drop the present PRES_PROD_FK constraint first)
Please find more on the constraint topic here:
http://download-east.oracle.com/docs/cd/B14117_01/server.101/b10759/clauses002.htm#CJAFFBAA
and here:
http://download-east.oracle.com/docs/cd/B14117_01/server.101/b10759/clauses002.htm#i1002273
Best regards,
Luis Morales,
ConsiteNicaragua.com

Similar Messages

  • Best practice when doing large cascading updates

    Hello all
    I am looking for some help with tackling a fairly large cascading update.
    I have an object tree that needs to be merged using JPA and Toplink.
    Each update consists of 5-10000 objects with a decent depth as well.
    Can anyone give me some pointers/hints towards a Best practice for doing this? Looping though each object with JPA's merge takes minutes to complete, so i would rather not do that.
    I have never actually used TopLinks own API before, so i am especially interested if TopLink has an effective way of handling this, preferably with a link to some related reading material?
    Note that i have a somewhat duplicate question on (Noting for good forum practice)
    http://stackoverflow.com/questions/14235577/how-to-execute-a-cascading-jpa-toplink-batch-update

    Not certain what you think you can't do. Take a long clip and open it in the Viewer. Set In and Out points. Drop that into the Timeline. Now you can move along in the Viewer clip and set new Ins and Outs and drop that into the Timeline. Clips in the Timeline are created from the Ins and Outs you set in the Viewer.
    Is that what you want to do? If it is, I don't where making copies of the clip would work for you
    Later, if you want to match up a clip in the Timeline to that master clip, just use Match Clip (find) in the timeline to find where it correaltes to your main clip
    You can have FCE automatically create subclips at camera cut points by using DV Stop/Start Detect if that is what you're looking for

  • Cascade Update in Oracle Constraint ?

    How can I create a Constraint in Oracle 9i with Cascade Update Option like On Delete Cascade.
    It means, if I change the primary key of master table, the foreign key of all the relevant child tables should be updated automatically.
    Any idea please ?
    Best Regards,
    Luqman

    Oracle doesn't intrinsically have the concept of a CASCADE UPDATE.
    From a data modeling standpoint, primary keys should never, ever change under any circumstances. If a column can ever change, it should not be used as a primary key.
    Tom Kyte has a package and some code to generate triggers that would do this sort of thing
    http://asktom.oracle.com/~tkyte/update_cascade/index.html
    but I would strongly suggest you change the data model rather than going down that path.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Updating PK with same value - effect on CASCADE UPDATE

    Hello,
    I would like to understand how sql server 2008 deals with cascade updates
    For example I have
    Parent table: Employee with column Id as varchar(20) primary key
    Child table with IdEmployee as varchar(20) foreign key
    I set up Cascade Update for those two tables, meaning any change to primary key in Employee table will cause update in child table rows that match affecting Id
    Scenario 1:
    Update Employee
    set Id = 'ABC',
    Name = 'something new'
    where Id = 'CCC'
    Result of child table: all rows with foreign key IdEmployee and value of 'CCC' are updated. Expected behavior.
    Scenario 2:
    Update Employee
    set Id = 'ABC',
    Name = 'something new 2'
    where Id = 'ABC'
    This time, i am doing something different. I am beside update of column Name with new value, also update primary key but
    with SAME value
    Question is: what is going to happen to child rows? Are they ALL going to UPDATE due to CASCADE UPDATE
    So far, what i did in order to find solution is:
    1. I put an timestamp column in child table that should update each time row gets updated
    2. I put a trigger for update event on child table that will write something to some log table
    *After I set up those two I ran example like above just to be sure timestamp gets changed as well trigger is being fired
    Results of updating PK with same value:
    1. Timestamp didnt change
    2. Trigger didnt fire
    Is this enough to make conclusion that updating primary key with same value ALONG with updating some other columns won't
    affect child tables with UPDATE CASCADE ON
    Update:
    Database is CI AS collation
    If i do following
    Update Employee
    set Id = 'abc',
    Name = 'something new'
    where Id = 'ABC'
    1. Timestamp will change
    2. Trigger will fire
    Conclusion: Case sensitive is important here!
    Thank you very much in advance
    Milos

    >>  would like to understand how sql server 2008 deals with cascade updates <<
    Your posting has a number of conceptual errors. 
    1. The terms “parent” and “child” are not RDBMS; they are used in network databases. We have “referenced” and “referencing” tables; they can be the same table.
    2. A table models a SET of things, so there is no “Employee” table unless you truly have a one-man company. We want a collective or plural name for the SET/table. A better name is “Personnel” for this table. 
    3. Her is no such thing as a generic “id” in RDBMS; it has to be “<something in particular>_id” to be valid. Identifiers are usually fixed length 
    4. It is very, very rude not to post DDL on a forum. You also do not know the ISO-11179 Rules for data element names. They do not change names from table to table! Does your name change whenever you use it in a new place?? NO! Same principle with data. 
    5. The ISO standard uses “<property>_<attribute property>” syntax, no the old PascalCase.
    6. Why did you post a useless narrative? How do we compile “I SET up Cascade UPDATE for those two tables,..” to test it?? 
    CREATE TABLE Personnel
    (emp_id CHAR(20) NOT NULL PRIMARY KEY,
     emp_name VARCHAR(25) NOT NULL,
    CREATE TABLE Health_Plan
    (health_plan_acct CHAR(20) NOT NULL PRIMARY KEY,
     emp_id CHAR(20) NOT NULL 
     REFERENCES Personnel(emp_id)
     ON UPDATE CASCADE
     ON DELETE CASCADE,
    Scenario 1:
    UPDATE Personnel
       SET emp_id = 'ABC',
           emp_name = 'something new'
     WHERE emp_id = 'CCC';
    Result of child table: all rows with foreign key emp_id and value of 'CCC' are updated. Expected behavior.
    Scenario 2:
    UPDATE Personnel
       SET emp_id = 'ABC',
           emp_name = 'something new 2'
     WHERE emp_id = 'ABC';
    This time, I am doing something different. I am beside UPDATE of column emp_name with new value, also UPDATE PRIMARY KEY but
    with SAME value.
    >> Question is: what is going to happen to child [sic: referencing]  rows? Are they ALL going to UPDATE due to CASCADE UPDATE. <<
    SQL uses a set-oriented model, so the whole table is updated as a unit of work in theory. 
    So far, what I did in order to find solution is:
    >> I put an timestamp column in child [sic: referencing] table that should UPDATE each time row gets updated <<
    Why? It is not in the SET clause list; it cannot change. As an aside,  The T-SQL TIMESTAMP is not the ANSI/ISO TIMESTAMP; it is DATETIME2(n) in T-SQL. The old TIMESTAMP is being deprecated because it stinks both in concept and implementation. 
    >> I put a trigger for UPDATE event on child [sic: referencing] table that will write something to some log table.<<
    TRIGGERs are fired by what is called a “database event” shown in the ON [DELETE | UPDATE] clause. T-SQL adds INSERT as an event. An update to any value or to no value at all is still an update. Depending on the collation, case may or may not matter in the final
    outcome. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How can I update my app store account ?

    Hi, I have a new Iphone and I wanted to add some applications from apple store.
    Unfortunately, I had a message saying that I was using app store on a new device (true) and they needed to check some security thing from my visa card. Unfortunately, I had a new  card and do not have the previous one anylonger (the previous one expires in 1 year but had to be cancelled).
    Therefore I am blocked and cannot get into my account.
    How can I update my bank account and get into the apple store again ?
    Thanks
    Nadiege

    Great, it worked. i could update the account from the laptop (but not from the phone).
    Many thanks for such a swift feedback !!

  • I upgraded from 3gs and want to use my old 3gs as an ipod. how can i update my new apple ID on the 3gs as it still shows a previous one that I had?

    I recently upgraded from 3Gs to Iphone4 and want to use my old 3Gs as an ipod. how can i update
    the user ID on the 3gs to a new one that I have as it is still showing a previous user ID?

    Settings>Store...tap the ID shown...sign out...sign back in with the ID you want to use.

  • How can i update data in JTable at run time ?

    i am trying to build a client/server architecture for conducting quizzes & online tests.. My client will return a object to the server after the test is over, which contains details about the participant, his score and other details. i am putting the incoming object to an Vector. I'll create a new thread each time for the incoming connection and insert the object to the Vector.. Now, please tell me tat, how can i update my table automatically at run time so tat, my table is updated whenever a new object is entered into vector..
    here is my code for the table..
    public class MyTableModel extends AbstractTableModel {
        String columNames[] = { "ID", "NAME", "COLLEGE", "SCORE", "CELL" };
        /** Creates a new instance of MyTableModel */
        public MyTableModel() {
            Main.List = new Vector();
            SetDefaultData();
        public int getRowCount() {
            return Main.List == null ? 0 : Main.List.size();
        public int getColumnCount() {
            return columNames.length;
        public String getColumnName(int column) {
            return columNames[column];
        public boolean isCellEditable(int row,int col) {
            return false;
        public Object getValueAt(int rowindex, int columnindex) {
            if(rowindex < 0 || rowindex >= getRowCount())
                return "";
            Student row = (Student)Main.List.elementAt(rowindex);
            switch (columnindex)
                case 0 : return row.id;
                case 1 : return row.name;
                case 2 : return row.college;
                case 3 : return row.score;
                case 4 : return row.cell;
            return "";
        public String getTitle() {
            return "Student Table";
        private void SetDefaultData() {
            Main.List.removeAllElements();
            Main.List.addElement(new Student("CS041","Keerthivasan M","MNM",95,"9884326321"));
            Main.List.addElement(new Student("CS012","Arun M","MNM",90,"9884825780"));
            Main.List.addElement(new Student("CS019","Balaji S","MNM",79,"9841742068"));
            Main.List.addElement(new Student("CS005","Anand R","MNM",89,"9884130727"));
            Main.List.addElement(new Student("CS045","Manish J","MNM",55,"9841624625"));
            Main.List.addElement(new Student("CS013","Mangal S","MNM",5,"9841961742"));
    }

    In the future Swing related questions should be posted in the Swing forum.
    how can i update my table automatically at run time so tat, my table is
    updated whenever a new object is entered into vector..You don't update the Vector directly. You should be creating a method in your TableModel, called "addRow(...)". This method will do two things:
    a) add the Student object to the Vector
    b) invoke the fireTableRowsInserted(..) method of AbstractTableModel. This will cause the table to be repainted.

  • Steps to put itunes (50 gb) on external drive and delete from imac.  How would I update my ipods and ipad from the external drive if I do this

    I am planning to put itunes library on external hard drive. My Imac is running out of room and itunes is 50+ gb of music.
    What steps do I take to do this.  Also, if I do so, how do I update my ipods and my ipad 2.  I do back up my files with time machine.  This would be a completely separate new external hard drive.  Thanks in advance for any help.

    Two ways:
    1. After transferring to the external drive create an alias to the iTunes Music folder on the external drive.  Copy the alias into your Home folder.  Rename the alias to "iTunes Music."  Delete the alias from the external drive.
    2. In the iTunes preferences click on the Advanced icon in the toolbar.  You should see a field labeled, "iTunes Media Folder Location."  Click on the Change button and select the /iTunes Music/ folder on the external drive.

  • I have osx 10.6.8 and safari 5.1.10, how do I update safari?

    I been using MSN.com as my homepage for some time.  Suddenly I cannot access it using the Safari browser on my iMac.  Instead I get an MSN "preview" page with a message that I am using an outdated browser.  My browser is Safari 5.1.10.  I opened the Apple Menu and chose Software Updates, but it does not provide a Safari update.  How do I update Safari and what version should I use for OSX 10.6.8? 

    Safari is now a part of OS X and there are different versions (5, 6 and 7) of it.
    To update Safari you must update OS X.

  • How can we update data in LDAP server using PL/SQL.

    Hi,
    How can we update data in LDAP server using PL/SQL program.
    Is there any sample code for refrence.
    Thanks,
    Tarun

    Hi Justin,
    Thanks for your help. You got my correct requirements.
    Tim's example returning all the attributes of current user which is admin user. Please correct me if I am wrong.
    I have the following information:
    the admin user and password,server info , port and ldap_base for admin.
    I have uid and password for regular user, I am trying find the ldap_base for regular user, which may be different from adminuser.
    Please help me.
    Thanks,
    Edited by: james. on Jan 12, 2009 5:39 PM

  • HT3576 Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    Ok so i have this iPod touch (3rd gen) and i'm trying to update it through iTunes and when i click  check for update it keeps saying this version of iPod software (2.2.1) is your current version. what do i do? how do i update it?

    You have a 1st generation iPod Touch. It can not be upgraded beyond iOS 3.1.3, it is available at the link below.
    http://support.apple.com/kb/HT2052

  • How do I update my ipod touch with my  new email address for my  itunes account?

    How do I update my ipod touch with my new email address for my itunes account?  I recently changed my email address and updated it on my itunes account but now my ipod keeps asking me for the password associated with my old email address.

    I did this and I still get a error message about either the
    password or the email account is incorrect!

  • How do I update my Macbook Air 10.6.8 to a newer version?

    How do i update my Macbook Air 10.6.8 to a newer version

    Open the Mac App Store and try downloading Mavericks. If you get told it's incompatible, choose About this Mac from the Apple menu, click here, and order a download code for Lion 10.7.
    Mac OS X 10.7 and newer don't support PowerPC programs such as Microsoft Office 2004.
    (97791)

  • How do i updates itunes on a macbook pro 2009 10.5.8 to newer 10.6.8

    Hey guys i hope someone can help me. I recenlty brought an older model macbook pro 2009 with itunes 10.5.8 on it. for a great low price of $ 300 dollars. How ever i cant update a newer version of itunes to replace the 10.5.8. So everytime I plug my new ipad into the older mac it says i need itunes 10.6.8 or higher. how do i update to a newer version for free???? youtube was not helpful or goole. So  I am stuck.

    Upgrading to Snow Leopard
    You can purchase Snow Leopard through the Apple Store: Mac OS X 10.6 Snow Leopard - Apple Store (U.S.). The price is $19.99 plus tax. You will be sent physical media by mail after placing your order.
    After you install Snow Leopard you will have to download and install the Mac OS X 10.6.8 Update Combo v1.1 to update Snow Leopard to 10.6.8 and give you access to the App Store. Access to the App Store enables you to download Mountain Lion if your computer meets the requirements.
         Snow Leopard General Requirements
           1. Mac computer with an Intel processor
           2. 1GB of memory
           3. 5GB of available disk space
           4. DVD drive for installation
           5. Some features require a compatible Internet service provider;
               fees may apply.
           6. Some features require Apple’s iCloud services; fees and
               terms apply.

  • How do I update the software on my Airport Express?

    Hello everyone,
    I have an Airport Extreme base station acting as WDS and an Airport Express station. I recently upgraded the security on the Airport Extreme base station from 128-WEP to WPA (Personal), but I don't know whether I have to do something to the Airport Express base station. It's green light is on. Do I need to do something? Also, how do I update the software in the Express? Whenever I open the Airport Admin Utility, the only thing that comes up on a scan is my Extreme base station. Any advice would be most appreciated.

    yes you need to update your Airpost Express. I just went through this last week with two of my Airport Expresses. I updated my Base and my Remote's light was green but was unable to view it in Airport Admin Utility. So this is what I ended up doing and it works great.
    First bring the Airport Express you are working on in the same room as your computer......just the ease of seeing what is going on with the Airport Express. Next you need to reset it.....take a paper clip and push in the little button next to the Audio port and hold in 10 seconds. Then unplug the unit wait 10 seconds and plug it back in. wait about 3 minutes and then you will need to use Airport Set Up Assistant. You will need to make sure you have WPA Personal on your Airport Express too.
    don't forget to make sure you have the update firmware too.
    http://www.apple.com/support/airport/
    I hope this helps.....
    Powerbook G4 1.67 15", 1 gig ram, 128 vram, 80 gig harddrive   Mac OS X (10.4.6)   Powermac G3 266 mt, Dell 5150,ibook G4, 1 gig shuffle, epson printers, airport

Maybe you are looking for