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

Preventing the insert of duplicate records

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

    Preventing the insert of duplicate records

    I am using SQL server and Alpha version 11.

    I have a grid that allows the insertion of records into a table that is used for requests for payment of invoices. I need to be able to determine if a combination of values already exists in the table before I insert the record. If an exact match of the combination of the invoice number, amount, vendor, and account code already exists, I want to be able to display an error message and not allow the insertion of the record. I know how to do that for a single value via Validation Rules on a single field by using the Cross-file Validation. I'm not sure how to do this when I need to check for a combination of field values as described above.

    Any help would be greatly appreciated.

    Tim Barker

    #2
    Re: Preventing the insert of duplicate records

    If you don't care about an SQL Error showing up (or you capture the error with Alpha) you can Just use SQL Server Managment Studio to set a unique constraint on those fields.

    On the other hand, curious minds want to know, why you would ever have two invoice numbers that are the same? Sometimes questions like yours come up when people are less familar with database design and are doing it in a way that causes these problems to arise when there is a different way to do things on the DB side that will keep this from happening in the first place.

    So, a better idea of how your tables are setup and how and when data is inserted might help someone here give you another alternative that's way easier to implement and has "best practices" in mind.

    Comment


      #3
      Re: Preventing the insert of duplicate records

      These reason I need to do this is because people are inadvertently entering in the same invoice twice. They enter it once, don't pay attention, and then enter it again. This is what I'm trying to prevent. I need to stop them from entering in the same invoice a second time. Plus, it is possible to have two vendors that used the same invoice number so that's why I need to do the validation (and prevention of inserting the record) on the combination of these fields.

      So my question is how to do this in Alpha. With all due respect Jinx, if you don't have that solution, please do not respond to my posts. I have a need to do it this way and for valid reasons based on my environment.

      Thanks,

      Tim Barker

      Comment


        #4
        Re: Preventing the insert of duplicate records

        Originally posted by tcbarker4 View Post
        These reason I need to do this is because people are inadvertently entering in the same invoice twice. They enter it once, don't pay attention, and then enter it again. This is what I'm trying to prevent. I need to stop them from entering in the same invoice a second time. Plus, it is possible to have two vendors that used the same invoice number so that's why I need to do the validation (and prevention of inserting the record) on the combination of these fields.

        So my question is how to do this in Alpha. With all due respect Jinx, if you don't have that solution, please do not respond to my posts. I have a need to do it this way and for valid reasons based on my environment.

        Thanks,

        Tim Barker
        That was rude. And I did give you a valid solution in the first sentence of my post.

        I asked what I did because people come on here and ask questions all the time about how to avoid duplicate records or how to create their own unique id (as opposed to the DB doing it automatically) and the answer, 95% of the time, is poor DB design.

        The "valid reason" you gave me above pretty much proves the point.

        Don't worry, I won't respond any more.

        Comment


          #5
          Re: Preventing the insert of duplicate records

          My response was not rude. I prefaced it with and sincerely meant "with all due respect". I simply have a question based on validation rules specific to Alpha 5. The application is well designed and so is the database schema. I have two seasoned DBAs on staff so design is not an issue. You are the one making the implied insinuation there is a database design issue and are obviously expressing your opinion based on things you are not familiar with.

          But I do appreciate your commitment not to respond to any more of my posts. At least in that respect, you've been helpful.

          Comment


            #6
            Re: Preventing the insert of duplicate records

            Hi Tim,
            If an exact match of the combination of the invoice number, amount, vendor, and account code already exists
            OTH, it is a bit curious that all 4 fields are required for a uniqueness test. Wouldn't a vendor's account code be unique to that vendor already? That might elimiate one test. I add a calculated KEYLINK field to my table when I have a situation like that which concentates the fields together. Then you can test for uniqueness on that field before the record is saved (and avoid a validation rule) and warn the user of a possible duplication.
            Robin

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

            Comment


              #7
              Re: Preventing the insert of duplicate records

              Robin,

              Normally you would be correct. The issue I have is the CSRs do not pay attention and can try and enter in invoices multiple times. An example is a CSR would enter in invoice 12345 from vendor 99999 for $135.00. Then they would set that invoice aside and it would inadvertently get mixed in with invoices yet to enter. A week later, the CSRs is entering invoices to be paid again and comes across the invoice in the example above. SO the CSR would enter in invoice 12345 from vendor 99999 for $135.00 again and the system would accept the entry and now a duplicate payment request exists. Currently, our A/P system will catch the duplicate entry but I want to prevent the invoice from being inserted into the database because it would recognized as a duplicate invoice. The vendor's code alone can not be used as the unique value as we have many invoices from the same vendor. The invoice alone cannot be used as the unique value because it is possible to have the same invoice number but from different vendors. That's why I need to use the combination.

              I like the idea of the Keylink field. I could do a concatenation operation and update the record in the AfterInsertRecord and AfterUpdateRecord server-side events. Would you use the CanInsertRecord Server-side Event to do the "uniqueness check"? I've used this server-side event for other things but never for something like this. Would you happen to have some code examples?

              Thanks for your help.

              Tim

              Comment


                #8
                Re: Preventing the insert of duplicate records

                Hi Tim,
                I'm afraid I can't be much help on server side events - strictly desktop here. But the database principle should still be the same. Unless there is a scenario where the same vendor might have a legitimate reason to present the same invoice # with different amounts! I think your uniqueness test only needs to be on vendor-invoice. That should be sufficient info to prompt the user this is a duplicate billing. Using a calculated key link field would then give the opportunity to warn the user of the possible duplication and perhaps then he could add an 'a' to the end of the invoice number if he wants to continue.
                Robin

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

                Comment


                  #9
                  Re: Preventing the insert of duplicate records

                  Tim,
                  What amazes me is that Jinx gave you the solution in his very first paragraph and you dissed him because you took a legitimate question of his a bit too personally.
                  Your problem is simple and easily coded for, and if your DBA's haven't figured out how to deal with this common issue then something is very wrong. Alpha provides all the tools to trap the returning SQL error.
                  You owe an apology to him, good sir! And there is no need to respond to my post.
                  Andy.

                  Comment


                    #10
                    Re: Preventing the insert of duplicate records

                    Tim,
                    may be not clean solution, but how about calling a sql query with three parameters vendor code, value and invoice no. and checking if the record count is more than 1 on onvalidation event and throwing error message ??

                    Comment


                      #11
                      Re: Preventing the insert of duplicate records

                      Andy,

                      You fall into that category as well. Please do not respond to any more of my posts. Your comments are unhelpful and do not provide a solution so you're wasting my time.

                      Tim

                      Comment


                        #12
                        Re: Preventing the insert of duplicate records

                        Wajeed,

                        Great suggestion. Thank you for providing a simply, concise, and useful solution. Your post was very helpful.

                        Thanks again,

                        Tim

                        Comment


                          #13
                          Re: Preventing the insert of duplicate records

                          Acid guy this Tim. Too bad I'm not a moderator.

                          Comment


                            #14
                            Re: Preventing the insert of duplicate records

                            Another helpful, useful, and constructive post. Bravo Andy

                            Comment

                            Working...
                            X