Prevent duplicates with locking

Hi,
There is a process that checks for a member record that has a given "firstname,lastname and email" or "firstname,lastname and phone". If a record doesn't exist, it goes a head and creates that member. This is a multi threaded web application, so a webuser can press the 'create' button multiple times triggering multiple processes that check for duplicate,and since there is no record of that member at time of checking, all the processes go ahead and create that member resulting in duplicates.
Is the there a way to prevent these duplicates? I know I can use table level locking during the duplicate check but that will lock up the whole table which may not be acceptable during heavy load times. I'm not sure if a "select ...for update;" will work in this case as there are no rows to lock since the member doesn't exist at the time of querying.
Thanks
Suneel

sb92075,
I don't think those indexes will work. They only prevent a new member from having the same phone number. It would still be possible for a new member to have the same phone number, firstname and lastname as an existing member. We are looking for is something like " *create unique index on (member.fname,member.lname,phone.phonenumber) where phone.memberid=member.memberid*". Is there such a feature in Oracle?

Similar Messages

  • Hi. I cant open my itunes?? comes up with locked layer or disc?? help !!

    Hi I cant open my itunes?? it comes up with locked layer or disc ?? Help please !!

    Sorry: once a device has been authorised for a particular iTunes account you can't change it to another until 90 days have passed. This is to prevent people cirumventing the restrictions of purchases to one account from consteantly swopping between accounts. You will have to wait for the 82 remaining days, and there is no workaround.

  • Easiest way to identify/delete/prevent duplicate documents

    I don't suppose that the text column (e.g. CLOB) is something that I can use the usual trick to delete duplicates with, is it? I would think rather than compare the actual text column, I'd need to calculate a checksum or something for each document and then delete rows with duplicate checksums. Or is there a better way? I'm trying to prevent, for example, a news article getting inserted 10 times because it's a UPI story that was carried by 10 different sites.
    Thanks.

    Your idea of a checksum is a good one. But I'd compute the checksum, and make it a unique constraint, which would PREVENT duplicates from being inserted. It's usually better to prevent them than to clean them up later.
    Tom Best

  • How to Prevent duplicates on Combination of Lookup columns in sharepoint 2010 using infopath 2010 form.

    Hi All,
    I have list with some Lookup columns like  City, Pin, and Text Column Name. All these are required columns.
    Now I want to prevent duplicates while submitting InfoPath form if a Combination of  City,Pin & Name. (like a Composite primary in Database is used.)
    Can some one help me on how to achieve this using InfoPath  2010 Rules, writing  rule in Xpath.
    Thanks in Advance.

    1. Add a secondary data connection to the list where the form will be submitted.
    2. Prior to submit via rules, set the query fields in the above connection: City, Pin & Name with values entered in the form. Query the data source and check if the result has values.
    3. Show error messages accordingly if exists else continue with Submit.
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Need advice on preventing duplicate entries in People table

    Hi,
    In my database, I have a "People" table where I store basic information about people e.g. PersonId, FirstName, LastName, Gender, etc.
    There will be lots of entries made into this table and I want to prevent duplicate entries as much as humanly possible. I'd appreciate some pointers on what I should do to minimize duplicates.
    My primary concerns are:
    Duplicate entries for the same person using the person's full name vs. given name e.g. Mike Smith and Michael Smith
    Making sure that two separate individuals with identical names do get entered into the table and get their unique PersonId's.
    Not even sure how I can even possibly know if two individuals with identical names are two different people without having additional information but I wanted to ask the question anyway.
    Thanks, Sam

    Thank you all very much for your responses.
    There are three separate issues/points here.
    It is clear that it is impossible to prevent duplicates using only a person's first, middle and last names. Once I rely on an additional piece of information, then things get "easier" though nothing is bullet proof. I felt that this was self evident but
    wanted to ask the question anyway.
    Second issue is "potential" duplicates where there are some variations in the name e.g. Mike vs Michael. I'd like a bit more advice on this. I assume I need to create a table to define variations of a name to catch potential duplicates.
    The third point is what Celko brought up -- rather nicely too :-) I understand both his and Erland's points on this as typical relational DB designs usually create people/user tables based upon their context e.g. Employees, Customers, etc.
    I fundamentally disagree with this approach -- though it is currently the norm in most commercial DB designs. The reason for that is that it actually creates duplicates and my point is to prevent them. I'm going for more of an object based approach in the DB
    design where a person is a person regardless of the different roles he/she may play and I see no reason in repeating some of the information about the person e.g. repeating first, last name, gender, etc in both customer and employee tables.
    I strongly believe that all the information that are directly related to a person should be kept in the People table and referenced in different business contexts as necessary.
    For example, I assign every person a PersonId in the People table. I then use the PersonId as part of the primary key in the Customers or Employees table as well. Obviously, PersonId is also a foreign key in Customers and Employees tables. This prevents the
    need for a separate CustomerId and allows me to centralize all the personal data in the People table.
    In my opinion this has three advantages:
    Prevent duplication of data
    Allow global edits e.g. if the last name of a female employee changes, it is automatically updated for her within the context of "Customer" role she may play in the application.
    Last but not least, data enrichment where a person may enter additional data about himself/herself in different contexts. For example, in the employee context, we may have the person's spouse information through "Emergency Contacts" which may come handy
    within the context of customer for this person.
    Having everyone in the People table gives me these three advantages.
    Thanks, Sam

  • Select and update with lock exclusive

    Hello Everybody
    In our application we have a table autonum     to handle unique keys for all other tables.
    In Autonum we have a column "SUCHBEGRIFF" char(40) unique KEY and a column "WERT" fixed(10,0).
    Suchbegriff has values like Rechnungsnr,Auftragsnr,Bestellnr ...
    Example:
    Befor inserting a record into table rechnungen we do:
    Select wert from autonun where suchbegriff = "Rechnungsnr" with lock exclusive.
    l_rechnrneu = wert + 1 
    update autonum set wert = ?l_rechnrneu where suchbegriff = "Rechnungsnr"
    commit
    (then l_rechnrneu is used for an insert into rechnungen command)
    This technic works for all tables (250) in our application.
    We have about 400 concurrent users working with maxdb 7.6 via odbc 7.6
    No problems since 2 years!
    Now we start some backgroundjobs from an xp-workstation.
    We have scheduled 5 jobs, starting every 5 minutes, same time.(Same user,same odbc-connection)
    Each job inserts records into a table joblogs and therefore needs a unique JOBLOGNR from autonum.
    Now we run into problems 2 or 3 times a day?
    <Sometimes the backgound jobs are running (waiting?) without inserting a record into joblogs (deadlock?)
    And more worse:
    Sometimes the insert into joblogs failes with "duplicate key" ??
    We don't know where to begin? Maxdb Problem ? Workstation problem?
    Any help welcomed
    Best regards
    Albert

    > >Gosh - that's information overloading at it's best...
    > We call this needed information.
    > What does our SAP-System? We have 1 mandt,60 accounting areas and about 200 werks!
    > Of course SAP uses internal unique keys for all tables, but we configured different "number intervals" for each werks.
    With "information overloading" I was referring to the multiple meanings you encode in just one column (your "rechnungs-no").
    SAP tables do not have this.
    As you wrote, there is "MANDT", "BUKRS", "WERKS" ... and the primary key is defined over all relevant columns.
    There is no primary key column where all the different meanings are concatenated together.
    So there aren't any surrogate keys here (a.k.a. AUTOID) used here - (ok except the infamous DDLOG sequence...).
    > >What do you do, when the value of an invoice has to be changed? Update the primary key of the table?
    > Update rechnungen set amount = xyz,...... where rechnungnr = nnn
    > We never change rechnungsnr,if the invoice was wrong we produce a credit for it and then write a new invoice
    So, you could use a sequence here instead as well.
    > > We don't use rollback when fetching logids from autonum.
    > >So what do you do, when connection fails, the database crashes or the client application hits an error?
    > >You use rollback. There is no way to avoid it.
    > >Your application gets a "duplicate key" error - the database performs a rollback of your last action. What does your application do then? Commit?
    > Sorry, i meant that we do not do rollbacks over  2 or 3 inserts or updates in different tables.
    > SQL-Command,On error = messagebox,errorlog,quit
    You don't handle the fetching of the new number in the same transaction as the actual insert of your application data in the same transaction?
    > >What isolation level do you use?
    > We use DATABASE ISOLATION LEVEL 0
    Hmm... did you read the documentation on SQL Locks?
    [Internals Course - SQL Locks|http://maxdb.sap.com/training/internals_7.6/locking_EN_76.pdf] :
    "Isolation level 0 does not offer any protection against access anomalies."
    Basically it might have happened that the same number is read twice.
    Perhaps the application is not always requiring locks when reading data from this table?
    > After connecting to the database via odbc we do
    > =SQLSETPROP(verbindungsnr,"Transactions",2)
    > 2 = Transaction processing is handled manually through SQLCOMMIT( ) and SQLROLLBACK( ). Read/write.
    > =SQLSETPROP(verbindungsnr,"DisconnectRollback",.T.)
    >
    >
    > So normal select commands are fired without a following commit.
    > Insert and update commands are fired with a following commit command.
    > Selects from autonum are fired with "look exclusive"
    Please be more detailed here.
    What is the exact sequence of actions here?
    1. Fetch number from number table and update number table.
    2. COMMIT
    3. Insert new application data with the just fetched number.
    4. COMMIT
    or
    1. Fetch number from number table and update number table.
    2. Insert new application data with the just fetched number.
    3. COMMIT
    And what does your application do with its data when a rollback occurs?
    Is it guaranteed that all variables are reset?
    > Nevertheless you dislike our design, do you think it would be better (quicker,safer...) to use an internal databases procedure to get
    > the next speaking number for a given "suchbegriff" from our autonum table? (no translation of the sql-command every time)
    No, currently we don't know what is causing the problem, so we cannot tell whether such a change would help. In fact, right now it would make things more complicated because we would less understand, what's happening here.
    Concerning your design: it's not about "liking" or "not liking it".
    I just pointed out some problems that result from the design as it is.
    > select   wert into :neuerwert FROM "BWPROGI"."AUTONUM"  WHERE upper(suchbegriff)     = upper(:suchkey) WITH LOCK EXCLUSIVE;
    > update  "BWPROGI"."AUTONUM" set wert = wert + 1 WHERE upper(suchbegriff)     = upper(:suchkey) ;
    > SET neuerwert = neuerwert + 1;
    > end;
    1. The WHERE clause UPPER(suchbegriff) = UPPER(...) is the best way to disable the efficient use of any index structure. Better make sure that your data is in the right format in the table when you enter it and then look it up without the UPPER() conversion. 
    2. I wouldn't perform the increment two times.
    Get the current value into your variable, increment this variable, set the current value in the table to the variable.
    > A char(10) return value would be nice and i don't know wether this would be the quicker way.
    Why should it? You would have to convert it first - that's additional work.
    Anyhow, to move ahead with your duplicate keys problem, you may perform a vtrace with the "stop on error" option.
    As your error is a duplicate key on a primary key constraint you should set "stop on error" to the error code "200".
    The next time your application hits the error, the vtrace automatically stops and we could examine what happened before.
    See [MaxDB database trace|https://wiki.sdn.sap.com/wiki/x/2yg] for details on how to activate the trace.
    When the error occurs next time and you caught it in the vtrace we can take a look at it.
    regards,
    Lars

  • Preventing duplicate post

    Does anyone have a suggestion regarding how to prevent duplicate posts with JSF?
    As an example, I have one form that allows users to carry out CRUD operations on the data that is being displayed. All successfully processed requests result in a post back to this same page.
    I really want to avoid the problems that could occur if a delete or new request gets reposted by an impatient user.
    Any suggestions are welcome. I should also note that for scalability reasons, I prefer to avoid solutions which require storing token, etc. in the session. I will settle for such a strategy in the absence of a better solution.

    Thanks to all who responded. Just a couple follow-up questions and comments.
    1. Can not use Shale. I'm in a heavily restricted corporate environment that limits me to IBM's (poor) implementation of JSF 1.0.
    2. Would rather not address the problem soley through the use of JavaScript because users can always disable JavaScript.
    3. Redirecting back to the page instead of forwarding back is not practical for three reasons. One, it will require my backing bean to make calls down into my application to retrieve data that would already have been readily available if I were forwarding, and I'm not comfortable with that performance decrease. Two, redirecting back to the form makes displaying of validation errors difficult. Three, redirecting to the page would successfully handle the circumstance where a user hits refresh, but doesn't handle the case of an impatient user who clicks the submit button twice while waiting for a response.
    If anyone can propose a solution that works within these constraints, let me know.
    Thanks again for those who are contributing.

  • How to prevent duplicates in your contacts

    When syncing two iphones via icloud with your computer how do I prevent duplicate contacts between both phones, icloud and yahoo?

    I have 11 people designated under faces.
    Do you see the 11 People when using the "Faces" view from the source list in the Library Inspector or from the "Faces" button in the toolbar?
    If you are using the Faces button from the toolbar, you may have been excluding faces stacks you already created. Then, when you enter search strings, Aperture will suggest names from your contacts and you may create the same stack again.
    Also, if the search field is not empty, you may already have more "Faces" stacks than you are actually seeing.
    As you certainly know, you can always unite "Faces" stacks by dragging a stack onto the other to merge them. The merged stack will use the name of the stack you dragged to.
    Regards
    Léonie

  • How to prevent duplicate entry in Details block

    Dear All
    I am using Forms 10g.
    I have a detail block.
    There is a column called Ip_Address.
    There i want to prevent duplicate entry .
    How can i do this ?

    hey i have a requirement that to restrict duplicate entry in both block(both multi record).the blocks are DEPT(MATER)
    EMP(DETAIL)
    the associated fieds in master block DEPT.DEPT_NO,in detail EMP.EMP_ID .
    I have done' Kevin D Clarke’s calculated item ' both in master and detail block
    its working fine for master block but in case of detail block its only respond to the current session(i.e. if the new value is inserted or save it will restrict another record to be inserted of that last record's value),it does not restrict duplicate value enter ,checking with other existing records(which are saved in earlier session,though after query it is shown on the form)
    can anyone guide me why its not working

  • How to prevent duplicate web pages from loading

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/930219]]</blockquote>
    how to prevent duplicate web pages from loading

    <s>Hi berternie, can you describe this in more detail?
    Are you saying the identical page loads in two different tabs? When does that happen -- when you click a link? or when you use a bookmark?
    Or do you have multiple tabs open every time you see your home page (i.e., when you start up, open a new window, or click the home icon)?</s>
    I see, you have more info in this thread: https://support.mozilla.org/en-US/questions/930219

  • Prevent duplicate on put() using DPL

    Given it is not possible to have composite index keys, what is the best way of preventing duplicate record creation on a put() using DPL. For example, for the following:
    @Entity
    public class Category {
    @PrimaryKey
    private Long recordID;
    private String description;
    private Integer type;
    private Long customerID;
    So how to avoid a duplicate put() on ( description + type + customerID ) ...... without a performance compromise.
    Can I extend the class with Comparator and then use set DatabaseConfig.setDuplicateComparator(Class<? extends Comparator<byte[]>> duplicateComparatorClass) or am I completely on the wrong track?
    Thanks, Len

    Does your GenericLookup constructor fill in the fields of the secondary key (the fields of the GenericLookupConstraint class)? You didn't include the constructor in your post.
    In your source code you've duplicated the fields, which makes me wonder whether you think that the key fields are not part of the entity. The secondary key is part of the entity, so there is no reason for the duplication.
    If you're still having trouble, please create a complete test program with a main() so we can try it and see what you're doing wrong.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Prevent duplicate data

    I would like to make sure there are no duplicate data entries in my JSP that populates an Oracle database with a table called MainTable. MainTable has an Id field that is the primary key, ValData with a varchar data type, Fid and Fid2 are number data types. Fid and Fid2 are foreign key values that are taken from another table.
    Id   ValData   Fid   Fid2
    1    abc         34    2
    2    efg          23    34
    3    zeo         25    43Sometimes someone can enter duplicate data and the ValData, Fid and Fid2 will end up like this:
    Id   ValData   Fid   Fid2
    1    abc          34    2
    2    efg           23    34
    3    zeo          25    43
    4    zeo          25    43Is there anything in Java I can implement to prevent duplicate data entry in the above example?

    Thanks,
    It now works after I added unique constraints to each of the fields.
    Google results showed me that ORA-00001 is Oracle's Duplicate message and I added a condition in the SQLException Catch area and it catches all my Duplicate entry attempts and shows message to the user.
    Here is what I have and would like to know if this is an efficient way I am doing this??
    try
    // db stuff
    catch (SQLException sqle)
        String message = sqle.getMessage();  
        if (message.indexOf("ORA-00001") != -1)
            out.println("Duplicate Data entry.");  
        else
          out.println("some other ORA error");  
    }

  • Prevent duplicate outputs within a table?

    Hi at all,
    we have a table in a subform. At the moment there are several lines with the same material. This is ok.
    Is it possible to prevent duplicate output in the form? We want to print out the rest of this line but set the material to blank.
    I tried this with scripting with java script:
    If (data.TF.DATA.field.rawValue == data.TF.DATA[-1].field.rawValue)
         data.TF.DATA.field.rawValue = "";
    Is it possible to point on the previous line with
    DATA[-1]
    This works for the conditional break so I hope this will works too.
    I don`t want to use group levels...
    Thanks.
    Timo

    Thanks for your answer.
    It works.
    data.formular.DATA.field::ready:layout - (FormCalc, client)
    If ($.rawValue == data.form.DATA[-1].field.rawValue) then
         this.presence = "hidden";
    endif

  • Prevent duplicate login

    Hi there,
    I wonder if there is any approach to prevent duplicate login to Weblogic
    server using the same userID and password.(weblogic provided or programmatic
    is OK). I tried to use a table to maintain the current active user
    information, but when the user just quits the browser or the weblogic server
    is shut down, this will not work because the flag still remain in the table.
    Does anyone have try it before or know how to do it?
    Thanks in advanced.
    Ken

    Thanks for your reply.
    Actually, I am now using the similar solution except that I place a static
    field(a hashtable) in the class that implements the
    HttpSessionBindingListener to record the current users rather than store the
    information in database table. Thus when the application server shuts down,
    I don't need to clear the dirty data in the table.
    Ken
    Andy <[email protected]> wrote in message
    news:[email protected]...
    >
    i'm doing the same thing with an application. i've extended theAuthFilter class
    and whenever a user logs into the application i insert a row into a"current users"
    table. i also set an object into the user's session that implements theHttpSessionBindingListener.
    when the session expires (either by the user by logging out or times outwithin
    weblogic) the server calls my class that was inserted into the user'ssession
    at which time i remove the row from the "current users" table.
    hope this helps -
    "Neil Smithline" <[email protected]> wrote:
    I believe that due to the loose coupling of a web browser and the server
    as
    defined in the HTTP spec, there is no way to ensure that both sides have
    an
    identical concept of "logged in". Any solution you propose will have
    errors
    as you described below. The server just plain can't tell the difference
    between a slow-to-respond user, a user who's browser has crashed, a user
    who
    is having network problems, etc... This is not a WLS specific problem,
    it
    is HTTP.
    Neil Smithline
    WLS Security Architect
    BEA Systems
    "Ken Hu" <[email protected]> wrote in message
    news:[email protected]...
    Hi there,
    I wonder if there is any approach to prevent duplicate login to
    Weblogic
    server using the same userID and password.(weblogic provided orprogrammatic
    is OK). I tried to use a table to maintain the current active user
    information, but when the user just quits the browser or the weblogicserver
    is shut down, this will not work because the flag still remain in thetable.
    Does anyone have try it before or know how to do it?
    Thanks in advanced.
    Ken

  • Preventing duplicate rows insertion

    suppose i have a table with 2 columns
    no constraints are there
    then how i will prevent duplicate rows insertion using triggers.

    but i tried to solve the poster's requirement.yes, but the trigger does not solve it.
    The example you posted above, try this:
    do the first insert in your first sql*plus session, and then without committing, open another sql*plus session and do the second insert.
    Do you see an error?
    SQL> create table is_dup(x number, y varchar2(10));
    Table created.
    SQL> CREATE OR REPLACE TRIGGER chk
      2      BEFORE INSERT ON is_dup
      3      FOR EACH ROW
      4  BEGIN
      5      FOR i IN (SELECT * FROM is_dup)
      6      LOOP
      7          IF (:NEW.x = i.x) AND
      8             (:NEW.y = i.y)
      9          THEN
    10              raise_application_error(-20005, 'Record already exist...');
    11          END IF;
    12      END LOOP;
    13  END;
    14  /
    Trigger created.
    SQL> insert into is_dup values(123,'MYNAME');
    1 row created.
    SQL>
    SQL> $sqlplus /
    SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 23 10:17:07 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> insert into is_dup values(123,'MYNAME');
    1 row created.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from is_dup ;
             X Y
           123 MYNAME
           123 MYNAME
    SQL> commit ;
    Commit complete.
    SQL> select * from is_dup ;
             X Y
           123 MYNAME
           123 MYNAME
    SQL>

Maybe you are looking for

  • Can't lock the screen anymore with a password

    I can't lock the screen anymore since I installed Mavericks. I have assigned a password to the screensaver in the system preferences, but when I activate the screensaver on my iMac 8,1 it does not ask for the password when I wake it up from sleep. I

  • Getting Document Icons to appear in the Finder

    I wanted to change the icons that would appear on the .tiff files that my Cocoa multiple document application creates. I did the following: I deleted the reference to the old .icns file from my XCode project. I trashed the old.icns file and emptied t

  • Sports Highlight Films

    I am making football highlight films and was wondering if anyone has had success in placing some type of a highlight feature on a specific player on the field ? Examples are an arrow or circle or square on the featured player only for a brief moment

  • Adobe flash player 10 works with Chrome but will not work with Int. explorer

    Adobe Flash playaer 10 works with Chrome but when I try to use it in Internet Explorer it says I do not have it installed but I do.

  • Adobe elements 10

    PLEASE HELP , I BOUGHT THE NEW ADOBE ELEMENTS BUT WHEN I PURCHASED IT , I GOT A GERMAN COPY ,AND THERE WAS NO INDICATION OR AN OPTION TO CHOOSE A LANGUAGE , I JUST ASSUMED THAT IT WOULD DOWNLOAD IN ENGLISH BY DEFAULT, HOW DO I FIX THIS