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

if statement

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

    if statement

    I am trying to normalize a large number of data. There are several instances of a name, some are missing middle name. I need to write an if statement and update fields so that, if last name, first name and address are the same then it will fill in the middle Init from another records (that has the same last, first and address). I also need to do this with e-mail, if last, first, etc are the same then it wll fill in the e-mail from another record.
    The purpose of this is to have all the records in the table match. The dups operation just doesn't do it.
    Please help someone. Thanks:)

    #2
    Re: if statement

    Check the update operation instead.
    And then again, in the end you will end up with duplicate records. Is that the object?
    sounds to me, you need to be deleting the ones that match all but missing the middle initial rather than duplicate the complete ones.

    Comment


      #3
      Re: if statement

      It is the update operation I want to do with the if statement. Yes there will be redundancy. I am creating a set: parent will have unique names, the problem is that if the child has 2 records and the only diff is middle initial, then I will have 2 unique records in the parent, so I am trying to eliminate this.

      Comment


        #4
        Re: if statement

        The Update operation sounds right.....I take it either of two ways as I read your question---both of which would use Update operations.

        Either you have just many different names that are missing information that another table can supply....OR...you have many names in a table (such as an Invoice table) that are missing information and a different table can supply.

        Regardless, the operation will take an expression and the genie may very well guide you through it....get to that point and then show us what expression you have tried and we can help.

        MAKE certain you backup up your data (at least once) prior to doing this!!!
        Mike
        __________________________________________
        It is only when we forget all our learning that we begin to know.
        It's not what you look at that matters, it's what you see.
        Henry David Thoreau
        __________________________________________



        Comment


          #5
          Re: if statement

          so the has to come from another table? There is no other table unless I create one.

          Comment


            #6
            Re: if statement

            huh? OK. I get it. You will have to open two instances of the table, one that goes through each record and gets the name/check for completeness, and a second one that you filter to middle initial field .not. blank to get the value and then all the records to for that name to change and update.
            Last edited by Mike Wilson; 06-25-2010, 04:01 PM.
            Mike W
            __________________________
            "I rebel in at least small things to express to the world that I have not completely surrendered"

            Comment


              #7
              Re: if statement

              Ok, let me make sure I understand. I open the same table twice. Then in one, I do a query if middle name is blank. What do I do with the 2nd instance of it?
              I know how to do this if i choose the ones that don't have the middle name blank and then run a post operation to fill in the blank middl enames I created on another table. Is this what you meant?

              Comment


                #8
                Re: if statement

                Senia, to begin with if you're using the concatenated field values of last, first, address, and zip (or state) to uniquely identify each record, you are not normalizing the table. You will have records with duplicate "key" values. The concatenated field values will not be unique, so they can't be the primary key for your table.

                Nevertheless, what you are attempting can be done. I think this may be a case where you will need a custom script. The script, in pseudo code, would do this:

                a) open the table
                b) loop through the records first to last
                c) if a record has an empty middle name or a missing middle initial then open a second instance of the table; set an index primary that sorts the records in order by your concatenated field values (excluding the middle name); fetches the first record that matches the current concatenated field value; examines it for a middle name; if present assigns the found middle name to the current record; else fetches and examines recs in the second instance of the table until all recs with the same concatentated field value have been checked or fetch past eof
                d) skip records that have a middle name or initial in them already
                e) don't forget to close both instances of the table

                Comment


                  #9
                  Re: if statement

                  ****Started this a while ago before Tom's method---which, of course, will work....but also means that xbasic will be required. The following should also work and utilizes genies.

                  I think I also understand now....one table with many of the same name but some do not have a middle name (or initial)....these you want to change to be exactly the same.

                  Let me know if this may be an easier concept.....
                  Creation of a "temporary" table that only has the full names--just people who have something for their middle name. This could most likely be produced from a Summary operation that simply looks for the record that has the Middle name field and groups on it.

                  Then use an Update operation to add the middle names to the actual table linked on First_Name, Last_Name, and Address.Or if what Tom stated is true, the concatenated field(s)

                  The same could be done for the email fields. Tom's method is more concise and less time would be involved....but if this is a one time update then time may be irrelevant.

                  Just the way I thought would be the simplest for others---Other ways am sure exist as well.
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: if statement

                    Maybe I took you down the wrong way.. maybe not.
                    Yes you can use update operation. Update operation does not use a transaction table (I think that's what Mike W was thinking).
                    In the update operation, use the General tab then assign a calc value to a field, then use an expression like previous() to make sure the values in the fields in question match the ones from the previous records. In the records selection, use selected records, use .t. for filter then order the records by those fields in question: First, Last, address etc. and also records in which middle="".

                    You could also do this using Post operation and As far as I can remember, yes you can use the same table both as the Master and Transaction, however this is a risky business as you might do things backward and copy blank middle field to the ones that are not. It is much better to copy the table to a new temp table, then use the temp table as your transaction table.

                    Better than all of the above is to write a simple script to do all of that. Here is a mock script:
                    First create an index with all records and sorted with first/middle/last/address
                    Code:
                    t=table.open("..your table..")
                    t.index.primary_put("..your index..")
                    t.fetch_first()
                    while .not.t.fetch_eof()
                    v1=t.first
                    v2=t.middle
                    v3=t.last
                    v4=t.address
                    t.fetch_next()
                    if t.first=v1.and.t.middle="".and.t.last=v3.and.t.address=v4
                    t.change_begin()
                    t.middle=v2
                    t.change_end(.t.)
                    t.fetch_next()
                    end while
                    t.close()

                    Comment


                      #11
                      Re: if statement

                      G,
                      I think the sort should be inverted maybe (descending)? A blank middle name would come prior to one with a value.
                      Mike
                      __________________________________________
                      It is only when we forget all our learning that we begin to know.
                      It's not what you look at that matters, it's what you see.
                      Henry David Thoreau
                      __________________________________________



                      Comment


                        #12
                        Re: if statement

                        good catch.

                        Comment


                          #13
                          Re: if statement

                          Tom, I agree that the concatenated field is not ideal. Here is a little more info on this: the database consists of licensed individuals. One of these individuals can have multiple license numbers in multiple states. He/She can also have multiple license types(so not just numbers). The information I received was from each of the 50 states and it is safe to say the data is all different. I was able to put it together all on one table (as oposed to having 50 different tables for each state). The total number of records is about 3 million.
                          Here is the problem, since a licensee can be listed in more than one state, and he can also have different licesnce types, in my final table he is appearing more than once. Also, a licensee can have multiple addresses depending on the state he is licensed in. For example, it is the same license number, but for one license type he has one address and or another license type he has another address.
                          I have to be able to search unique names by license type and then export an address, email, phone number for each agent.
                          Chances are very slim that one licensee with the same last, first and middle name in one state will appear twice.
                          The data to this database will be added on a large scale, like 100k agents. If I create a unique ID field I'd have to make sure that there are no dup ID's created, not sure how to ensure that.
                          Last edited by FreeBird; 06-25-2010, 05:07 PM.

                          Comment


                            #14
                            Re: if statement

                            Originally posted by FreeBird View Post
                            Chances are very slim that one licensee with the same last, first and middle name in one state will appear twice.
                            Probably as slim as Michael Moore!
                            I think you better off with something like all of the above plus license Number. License number, one would assume and wrongly so, that it should be unique, but the conglomerate of all of the above should offer more unique values
                            That said.. not sure what is the point of the above exercise?
                            You need a set with the agents as the parent, then licenses as child. The parent does not have to have duplicate records.

                            Comment


                              #15
                              Re: if statement

                              You are right Gabriel. You just gave me an idea which I actually thought of a while back and then it got lost in the ocean of other data.
                              Thanks Gabriel, MikeC and Tom. i'm going to work on this tonight :)

                              Comment

                              Working...
                              X