Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Filling fields from another table in mass

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Filling fields from another table in mass

    Thanks for any speedier code in advance.

    scenario.

    main table has matching field
    from table has index on the matching field
    matching fields are not overwritten
    38 matching fields to fill from one other table (1 field is a small rtfmemo)
    By using operations and lookupc(), lookupL(), etc., it takes about 3.5 hours on a fast local machine but it does work well.
    Joining gave a few unpredictable results, but a lot faster.
    Currently using a function where the operations/update filled was copied from.

    May be because there are just over 100,000 records and 38 fields.

    Question is: Is there a faster method I missed and if so, some ideas?
    Dave Mason
    [email protected]
    Skype is dave.mason46

    #2
    Re: Filling fields from another table in mass

    Hi Dave,
    Are you using an append to update one table with data from another, or are you also adding new records at the same time?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #3
      Re: Filling fields from another table in mass

      Hi Robin,

      I do an append to get the field values from a server on a lan.
      Once that is done, I am combining the records from one table into empty fields in another one. all local db- if I tried the field update over the lan, it would be extremely slow.
      It would be great if I could append from 2 tables at one time, but that does not happen. I tried to append from a set, but alas, that did not happen either.
      After the appends are done with the many tables I have, the one tables records need to be brought to the main(keeper) table. The other table will be discarded after all is done.
      38-65 minutes just to do all the appends. And add from 3 to 4.5 hours for the fields to be updated. >>> Long time!

      Call them tbl1 and tbl 2
      both have the right records.
      running lookup() on each field in the

      possibly, I could run a table intersect and the append from the created table name faster??
      Dave Mason
      [email protected]
      Skype is dave.mason46

      Comment


        #4
        Re: Filling fields from another table in mass

        What is the purpose of the look up and when are you doing that? Is it a separate process?

        Still trying to get a handle on what you are doing....
        Robin

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

        Comment


          #5
          Re: Filling fields from another table in mass

          It can be done by operations/field update. pick the correct table, Choose a field( I have 38 of them) and do the lookup() to fill that field from a corresponding field in another table. field is name, then
          lookup("f", idnum, "name", "tablename", "idnum") should get that field filled by 100,000 times if there are 100,000 records. Do that 38 times for 38 fields??? = a lot.

          I guess I am looking for something faster than lookup()'s
          Last edited by DaveM; 11-23-2014, 05:05 PM.
          Dave Mason
          [email protected]
          Skype is dave.mason46

          Comment


            #6
            Re: Filling fields from another table in mass

            I would use table.open if I understand what you are doing.
            Code:
            tbl1 = table.open(main)
            tbl1.index_primary_put("matching_field_index")
            tbl2 = table.open(from)
            tbl2.index_primary_put("matching_field_index")
            tbl2.fetch_first()
            while .not. tbl2.fetch_eof()
            vnfind = tbl1.fetch_find(tbl2.matching_field.value)
            if vnfind > 0
            	tbl1.change_begin()
            	tbl1.field1 = tbl2.field1.value
            	...37 more fields...
            	tbl1.change_end(.t.)
            end if
            tbl2.fetch_next()
            end while

            Should have added .BATCH_BEGIN()..... .BATCH_end() in the code
            Last edited by Allen Klimeck; 11-23-2014, 07:47 PM.

            Comment


              #7
              Re: Filling fields from another table in mass

              Thank You Allen, That looks like the way to go. I will test it later tonight.
              Dave Mason
              [email protected]
              Skype is dave.mason46

              Comment


                #8
                Re: Filling fields from another table in mass

                I think Allen needs to add a fetch for tbl1 in there too, else you will only update one record in tbl1 - or so it seems to me.

                - or -

                Perhaps I should actually go and look up the doc on fetch_ find....
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                  #9
                  Re: Filling fields from another table in mass

                  Copy the set to a table.

                  Use the append operation not xbasic enter.begin/end - much faster because it runs in C++

                  Using lookups will kill the speed.
                  Al Buchholz
                  Bookwood Systems, LTD
                  Weekly QReportBuilder Webinars Thursday 1 pm CST

                  Occam's Razor - KISS
                  Normalize till it hurts - De-normalize till it works.
                  Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                  When we triage a problem it is much easier to read sample systems than to read a mind.
                  "Make it as simple as possible, but not simpler."
                  Albert Einstein

                  http://www.iadn.com/images/media/iadn_member.png

                  Comment


                    #10
                    Re: Filling fields from another table in mass

                    Dave, the lookup() function opens a fresh instance of the table each time it's called. this is among the slowest things alpha does. Opening the source table and looping through its records, as Allen suggests, should be much faster.

                    Comment


                      #11
                      Re: Filling fields from another table in mass

                      Originally posted by Tom Cone Jr View Post
                      Dave, the lookup() function opens a fresh instance of the table each time it's called. this is among the slowest things alpha does. Opening the source table and looping through its records, as Allen suggests, should be much faster.
                      Yes the method that Allen K recommends is faster than the lookup.

                      The append operation is another level faster and is worth the effort to build the appropriate pre-processing.
                      Al Buchholz
                      Bookwood Systems, LTD
                      Weekly QReportBuilder Webinars Thursday 1 pm CST

                      Occam's Razor - KISS
                      Normalize till it hurts - De-normalize till it works.
                      Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                      When we triage a problem it is much easier to read sample systems than to read a mind.
                      "Make it as simple as possible, but not simpler."
                      Albert Einstein

                      http://www.iadn.com/images/media/iadn_member.png

                      Comment


                        #12
                        Re: Filling fields from another table in mass

                        This is not an append operation candidate.
                        There are 45 fields in the first table that are already filled. The 38 new fields are blank to be filled from another table, I can find no way of doing this with an append.
                        I think Allen's method is going to be very much faster than using lookup(). However, this will only have to be done one time once in production environment and writing the code may take a lot longer.
                        Dave Mason
                        [email protected]
                        Skype is dave.mason46

                        Comment


                          #13
                          Re: Filling fields from another table in mass

                          But Dave, if tbl1 and tbl2 have a matching key field, then why wouldn't an append work? In the mapping you only need to map the 38 fields you are updating.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                            #14
                            Re: Filling fields from another table in mass

                            an append adds to records so I would have:
                            name1
                            name2
                            name3
                            name4
                            address1
                            address2
                            address3
                            address4
                            instead of:
                            name1 address1
                            name2 address2
                            name3 address3
                            name4 address4
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                              #15
                              Re: Filling fields from another table in mass

                              Originally posted by DaveM View Post
                              an append adds to records so I would have:
                              name1
                              name2
                              name3
                              name4
                              address1
                              address2
                              address3
                              address4
                              instead of:
                              name1 address1
                              name2 address2
                              name3 address3
                              name4 address4
                              No that is incorrect ( or at least incomplete).

                              There is an option of the append operation to add unique, replace existing.

                              appendoptions.PNG

                              That way if a record doesn't exist in the target, the append adds it. Otherwise the values are updated.

                              On the other hand:

                              If you are 100% certain that the records exist in the target, you can make the target table the primary table of a set, link to the other tables and use an update operation to fill values in the parent table with values in the child table(s).
                              Al Buchholz
                              Bookwood Systems, LTD
                              Weekly QReportBuilder Webinars Thursday 1 pm CST

                              Occam's Razor - KISS
                              Normalize till it hurts - De-normalize till it works.
                              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                              When we triage a problem it is much easier to read sample systems than to read a mind.
                              "Make it as simple as possible, but not simpler."
                              Albert Einstein

                              http://www.iadn.com/images/media/iadn_member.png

                              Comment

                              Working...
                              X