[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference orarep::nomahs::dec_data_distributor

Title:The Replication Option for Rdb
Notice:Product renamed to Replication Option for Rdb
Moderator:BROKE::PROTEAU
Created:Wed Mar 02 1994
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:287
Total number of notes:1231

254.0. "Modifying columns in a REPLICATION transfer" by ORAREP::BASICO::ISMAN1 () Tue Dec 17 1996 04:38


  Hi,


	Could anyone tell me what would happen if we change a column definition
  (actually we want to change the default value, not the data-type,  for three
  columns) in a table that it's a source one in a REPLICATION transfer? 
  Would these column definition changes take effect in the existing rows, so 
  the replication transfer would pass all the existing rows affected, or only 
  to the new incoming rows ?
  
  Thanks very much in advance, and best regards,


 	Marta
T.RTitleUserPersonal
Name
DateLines
254.1There are two default valuesBROKE::PROTEAUJean-Claude ProteauTue Dec 17 1996 08:2728
    
    Marta,
    
    When the DDAL product was first implemented years ago, Rdb would not
    allow any changes to the definition of source tables which were marked
    to be replicated.  In recent years there was a slight change to this. 
    One or two attributes are allowed to be changed, but I don't recall
    which ones.  Default value might have been one of them.
    
    Assuming for the moment that Rdb will allow the default value to
    change, be aware that that attribute is not then changed in the target
    table definition.  You have to do that yourself.
    
    Now, there are two default value attributes.  One is applied by Rdb to
    a column value as a row is being stored in the source database if the
    column value passed to Rdb is null.  If that is the one you're talking
    about, the change would only affect new rows inserted into the source
    table.  The other type of default value is applied when a row is read
    from the source database.  If at that time a column value is null, the
    default value is passed instead.  In such case, the default value is
    passed to old and new rows alike.  However, if you are talking about an
    existing replication transfer (I assume you are), the affected columns
    would not appear as changed columns to be replicated.  You'ld have to
    start the transfer over from the beginning (STOP, REINITIALIZE, START).
    
    It's difficult to explain in a few words.  I hope this makes sense.
    
    Claude
254.2NOVA::SMITHIDon't understate or underestimate Rdb!Tue Dec 17 1996 10:1324
~    Now, there are two default value attributes.  One is applied by Rdb to
~    a column value as a row is being stored in the source database if the
~    column value passed to Rdb is null.

This is not true.  The SQL DEFAULT is only used if the column is not
referenced in an INSERT statement.  If the column value is null then NULL is
stored.

~If that is the one you're talking about, the change would only affect new
~rows inserted into the source table.

~The other type of default value is applied when a row is read from the source
~database.  If at that time a column value is null, the default value is passed
~instead.  In such case, the default value is passed to old and new rows alike. 

The other form of default is the DEFAULT FOR DATATRIEVE and is only used by
the DTR product, not by Rdb at all.  Not for READ and not for WRITE...

If you were referring to MISSING_VALUE then that value is used to set the NULL
bit on insert, and it is returned if the row is null.

I do not believe you'll be able to ALTER the table to change the DEFAULT.

Ian
254.3I need a memory overhaulBROKE::PROTEAUJean-Claude ProteauTue Dec 17 1996 11:244
    
    I stand corrected.
    
    Claude
254.4ORAREP::BASICO::ISMAN1Wed Dec 18 1996 03:3923

  Hi Claude,


     Thank you very much for your answer.

     Yes, you're right, we are talking about an existing Replication transfer
     and we want to define a default value for some columns with a NULL value.
     So, if we make these changes to the source table, these changes are
     going to affect to the new rows that are going to be inserted, so only
     these new rows are going to be copied to the target database by the 
     transfer, the existing rows are going to stay unchanged. We have to apply
     the same changes to the target database, or stop and recreate the transfer
     from the beginning, are we right ? 


     Awaiting for your comments.

     Best regards and  Happy Christmast

	Marta.
    
254.5ORAREP::BASICO::ISMAN1Wed Dec 18 1996 07:0113

  Claude and Ian,


     I'm sorry for my last reply (*.4), I've written it without haven't read
  Ian's reply. After having read all them, we've realized that we must use 
  another workaround.

  Thank you very much indeed and best regards,


     Marta
254.6NOVA::SMITHIDon't understate or underestimate Rdb!Wed Dec 18 1996 13:3712
When a transfer is defined on a table you can not perform the following:

    add a column
    drop a column
    alter the data type of an existing column
    add or drop a DEFAULT clause

I am not sure why we have the restriction of DEFAULT.  It is only used on
INSERT and the actual value will get transferred automatically.  We need to
review this, it looks like someone was being over cautious.

Ian