Results 1 to 4 of 4

Thread: DUF 2.1.1: Thoughts about OnPostUpdate at cDbUpdateVersion

  1. #1
    Join Date
    Feb 2009
    Posts
    862

    Default DUF 2.1.1: Thoughts about OnPostUpdate at cDbUpdateVersion

    Hello,

    Just a follow up on this https://support.dataaccess.com/Forum...491#post324491

    In our application we do database structure changes and other kind of operations, for example, update values on each row conditionally to other values on that row (so ApiColumnUpdateValue is not an option).

    DUFCodeGenerator is great because you don't have to code the changes, you simply take a "screenshot" and DUF take care of what it is needed to perform the update.

    So, my first thought was: we need an event on cDbUpdateVersion called OnPostUpdate.
    Later I realized that this is not a good idea because OnPostUpdate is going to be overwriten each time you generate the pkg with DUFCodeGenerator.

    What about, when an OnUpdate of cDbUpdateVersion is finished, prior to call the next OnUpdate, launch OnPostUpdate of cDbUpdateHandler with a parameter? Same feature could be added to OnPreUpdate.
    Something like this:
    Code:
    Object oDbUpdateHandler is a cDbUpdateHandler
        Object oDbUpdateVersion1_0 is a cDbUpdateVersion
            Set pnVersionNumber to 1.0
    
            Procedure OnUpdate
                // Do some structure table changes
            End_Procedure
        End_Object
    
        Object oDbUpdateVersion2_0 is a cDbUpdateVersion
            Set pnVersionNumber to 2.0
    
            Procedure OnUpdate
                // Do some structure table changes
            End_Procedure
        End_Object
    
        Use DUF_MultipleTables3_0.pkg
        Use DUF_MultipleTables4_0.pkg
    
        // If nVersion is <= 0 then the wole updates have finished?
        Procedure OnPostUpdate Number nVersion
            Case Begin
                Case (nVersion = 0.0)
                    // The whole update has finished    
                    Case Break
                Case (nVersion = 3.0)
                    // I need to do additional task for version 3.0
                    Case Break
            Case End
        End_Procedure
    End_Object
    Maybe it sounds bad because you are doing specific version tasks at parent object instead of use the version object...
    We are always in a continuous learning mode, and the more we know, the more we realise that we don't know anything.

  2. #2
    Join Date
    Feb 2009
    Location
    Goteborg, Sweden
    Posts
    3,189

    Default Re: DUF 2.1.1: Thoughts about OnPostUpdate at cDbUpdateVersion

    Hi there,

    The OnPostUpdate event most certainly could be changed to something along the lines of your suggestion.

    But before doing so, may I ask you a question?

    If the event is version dependent, why not just add your code to another cDbUpdateVersion object?
    And place the new object right after e.g. the auto-generated package line;


    Like;
    Code:
       Use DUF_MultipleTables4.0.pkg
     
       Object oDbUpdateVersion4_1 is a cDbUpdateVersion
            Set pnVersionNumber to 4.1
    
            Procedure OnUpdate
                // Do your data-value update here. Whatever you need to do can be done here.
            End_Procedure
        End_Object
    Nils Svedmyr
    RDC Tools International
    www.rdctools.com

    "The problem with internet quotes is that you don't know if they are true."
    Abraham Lincoln

  3. #3
    Join Date
    Feb 2009
    Posts
    862

    Default Re: DUF 2.1.1: Thoughts about OnPostUpdate at cDbUpdateVersion

    Hello Nils,

    What you say is going to do the work.

    The only problem I see is that it sounds a bit strange to have to create two cDbUpdateVersion to make one update.

    I don't have any problem right now so it is fine as it is. Let's see what others have to say.

    Regards.
    We are always in a continuous learning mode, and the more we know, the more we realise that we don't know anything.

  4. #4
    Join Date
    Feb 2009
    Location
    Goteborg, Sweden
    Posts
    3,189

    Default Re: DUF 2.1.1: Thoughts about OnPostUpdate at cDbUpdateVersion

    Although I can agree to a certain extent that it might be a bit strange for two update objects to make one update. But if you think about it, it is really two separate updates. One is doing database structure updates and the other is changing data.

    And I also think that this will keep the code more readable and easier to understand.
    Nils Svedmyr
    RDC Tools International
    www.rdctools.com

    "The problem with internet quotes is that you don't know if they are true."
    Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •