Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Copy-Method in DataDictionary-Class

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Location
    Oederan, Germany
    Posts
    88

    Question Copy-Method in DataDictionary-Class

    Hello to all,

    is there any method or way to get a Copy of a current row in a DataDictionary-Object?

    I want to get a row for example by searching it with:
    Code:
    Send Find of oTest_DD EQ 1
    and then i want to get a copy of it as a new row. Then i would change some informations to handle duplicate records and so on and save it to the database through:
    Code:
    Send Request_Save of oTest_DD
    For the global file buffer, there exists a command, called:
    Code:
    NewRecord table
    Thats what i need, but i want to use the advantages of a DataDictionary with the Update- and Backout-Functions and so on...

    Does someone knows any way to get this?
    Degger is: Bernhard Veit - SBH Datensysteme - Germany

    ...ganz nach dem Motto: "Wie man's macht, macht man's falsch!"

  2. #2
    Join Date
    Feb 2009
    Location
    Pine Island, Forida
    Posts
    2,056

    Default Re: Copy-Method in DataDictionary-Class

    No. Many discussions on this. You have to create your own code in a subclass to do this.
    Frank Valcarcel
    Cove Systems, Inc.
    Pine Island, Florida USA
    fv@covesys.com
    (239) 823-7976

  3. #3
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    7,808

    Default Re: Copy-Method in DataDictionary-Class

    Hi Bernhard,

    the most typical way of doing this is perhaps in a DDO, but you can do it in any DD class or object. You can use the NewRecord command and then simply loop through the table.columns to duplicate them.

    P.S.: Schönes Motto!

  4. #4
    Join Date
    Feb 2009
    Location
    Peoria, IL
    Posts
    5,318

    Default Re: Copy-Method in DataDictionary-Class

    Here is something I found on the forum that I am using...

    Code:
        // Contributed by Allan Kim Eriksen of NOVAX A/S
        // http://support.dataaccess.com/Forums/showthread.php?42133-Make-a-copy-of-the-current-record-in-a-datadictionary-object.&p=204161#post204161
              
        Procedure DoMakeNewCopy
                Integer iMaxField iCurField iDDFile iCurFile iMaxFile iParentFile
                Handle hParentDD
                RowID rwOld rwCurrentID
                RowID[] rwParents
                Boolean bFound
                String sData
                Get Data_Set_Server_Count to iMaxFile
                Decrement iMaxFile
                For iCurFile from 0 to iMaxFile
                    Get Data_Set_Server iCurFile to hParentDD
                    Get CurrentRowId of hParentDD to rwParents[iCurFile]
                Loop
                Get Main_File to iDDFile
                Get_Attribute DF_FILE_NUMBER_FIELDS of iDDFile to iMaxField
                Get CurrentRowId to rwOld
                Send Clear
                Move (FindByRowID(iDDFile, rwOld)) to bFound
                If bFound Begin
                    For iCurFile from 0 to iMaxFile
                        Get Data_Set_Server iCurFile to hParentDD
                        Get CurrentRowId of hParentDD to rwCurrentID
                        If (not(IsSameRowID(rwCurrentID, rwParents[iCurFile]))) Begin
                            Get Main_File of hParentDD to iParentFile
                            Send FindByRowId of hParentDD iParentFile rwParents[iCurFile]
                        End
                    Loop
                    For iCurField from 1 to iMaxField
                        Get_Field_Value iDDFile iCurField to sData
                        Set Field_Changed_Value iCurField to sData
                    Loop
                    Clear iDDFile
                End
        End_Procedure
    I added this to my own custom DD class.
    Chuck Atkinson

    All generalizations are false, including this one - Mark Twain

  5. #5
    Join Date
    Feb 2009
    Location
    Queens, NY, NY
    Posts
    6,583

    Default Re: Copy-Method in DataDictionary-Class

    Chuck,

    Have you had any issues with this code since 18.2? My "duplicate Item" button uses it, but it's fubar now, and I'm not sure why, could be 18.2, or it could be just me.

    MM.
    Michael Mullan.
    Danes Bridge Enterprises.

    ++++++++++++++++++++++++++++
    There is just today. Tomorrow is a concept
    that is mostly theoretical. -- GM Wylie
    ++++++++++++++++++++++++++++

  6. #6
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    9,610

    Default Re: Copy-Method in DataDictionary-Class

    While I'm not Chuck - I have this in a # of 18.2 views/DDs & it's working fine.
    Garret

    All my life,I always wanted to be somebody. Now I see that I should have been more specific.


  7. #7
    Join Date
    Feb 2009
    Location
    Queens, NY, NY
    Posts
    6,583

    Default Re: Copy-Method in DataDictionary-Class

    Bummer that, I was hoping to make it "Somebody Else's problem"

    MM

    :-)

    Michael Mullan.
    Danes Bridge Enterprises.

    ++++++++++++++++++++++++++++
    There is just today. Tomorrow is a concept
    that is mostly theoretical. -- GM Wylie
    ++++++++++++++++++++++++++++

  8. #8
    Join Date
    Mar 2009
    Location
    New Zealand
    Posts
    1,519

    Default Re: Copy-Method in DataDictionary-Class

    Quote Originally Posted by Michael Mullan View Post
    Bummer that, I was hoping to make it "Somebody Else's problem"

    MM

    :-)

    The only reason why it would fail would be either:
    1. Overlap fields
    2. Binary fields
    Regards,
    Raveen Sundram

    Software Development Manager
    Excellent Software Ltd
    Auckland, New Zealand
    www.xls.co.nz

  9. #9
    Join Date
    Feb 2009
    Location
    Peoria, IL
    Posts
    5,318

    Default Re: Copy-Method in DataDictionary-Class

    I think I still have it in the class but I don't think I've used the method in 18.2 The app that uses it is still 18.0 Define "fubar" ... I mean I know what fubar stands for but are you getting errors or it just doesn't work?
    Chuck Atkinson

    All generalizations are false, including this one - Mark Twain

  10. #10

    Default Re: Copy-Method in DataDictionary-Class

    We use it in our application in 18.2 and it still works for us. Do you have an example code where it does not work?

Tags for this Thread

Posting Permissions

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