Can some one tell me a better way...

Hi All..
I work on a web application. I create user ids for people logging into my application. here I have a small problem.. This is what I am currently doing...
When I create a new user, I assign a new user id to the user and store all hi info.
All our user ids are stored in User_ID table and user info in User_Info table.
First I get the max user id from the User_Id table.
int iuserid = select max(User_ID) from User_ID;
Then I add ' 1 ' to this and assign it to new user.
iuserid = iuserid+1;
insert into User_id values(iuserid, <ssn> );
Then I store all user info in User_info table..
insert into User_info(iuserid, <first_name>, <last_name>,...);
Both these SQLs are executed as a transaction.
The problem that I have...
It works fine in a normal environment and in my testing.
But when the load inceases, before I insert into the User_info, another user tries to get the max User_id from User_ID table, then it conflicts..
I have seen occurences of User_Info storing the info of a different user against the User_id when many people are accessing the app at the same time.
Can some one tell me a better way to handle this scenario..
Appreciate all you help..
TIA..
CK

Hi,
assuming that the requirement for user_id is only for uniqueness (primary key requirement) not continuosly.
perhaps can try this,
1) create a table to keep the max id for each table's key.
e.g.
create table key_id_lookup
key_name char(n),
current_value number(m)
where n & m is the size of the field
2) for each creation of entry in the user_id table, lookup the value in the key_id_table and increment it after retrieval.
e.g. current_id = select current_value from key_id_lookup where key_name = 'user_id_key';
current_id+=1;
update key_id_lookup set current_value = current_id where key_name = 'user_id_key';
something similar to use of sequence if your database support it.
3) continue with the creation of record in other tables. now obtain the time stamp of creation and append with the current_id obtained. e.g. timestamp = 132456872; size of m is 5, user_id = 132456872 x 100000 + current_id;
this should give you a unique key at creation time.
There should be other better ways of resolving this(like locking the table for the update operation but affect performance, etc), depending on the feature supported by the database in use.
Hope this can help as last resort if other options not available.

Similar Messages

  • Please please can some one tell me how do you charge ur ipad with ur laptop. it doesn't chage wen I put use the wire. only charges when I plug the socket in.

    please please can some one tell me how do you charge ur ipad with ur laptop. it doesn't chage wen I put use the wire. only charges when I plug the socket in. Iv never used an ipad b4 so don't really know much. Hope some one knowz.

    The quickest way (and really the only way) to charge your iPad is with the included 10W or 12W USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (2.5W, most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    How to Save and Prolong the battery life of your new ipad
    https://discussions.apple.com/thread/4480944?tstart=0
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
    iPhone, iPod, Using the iPad Charger
    http://support.apple.com/kb/HT4327
    Install and use Battery Doctor HD
    http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
    To Extend a Device’s Battery Life, Get to Know It Better
    http://tinyurl.com/b67c7xz
    iPad Battery Replacement
    http://www.apple.com/batteries/replacements.html
    In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
     Cheers, Tom

  • I have a targus 4.0 bluetooth usb adapter and so i can pair my iphone 4s and ipad air wirelessly, it seems to pair ok but when i try to connect i get a error message or not compatible. can some one tell me if it i can use this

    i have a targus 4.0 bluetooth usb adapter and so i can pair my iphone 4s and ipad air wirelessly, it seems to pair ok but when i try to connect i get a error message or not compatible. can some one tell me if it i can use this bluetooth with my devices, thanks

    sos1der wrote:
    pairing the apple equipment is not a big deal just wanted to add songs from itunes wirelessly.
    You can only add songs to your iOS device from iTunes via Wi-Fi sync or via your cable, not Bluetooth.
    sos1der wrote:
    but i tried paring my LG bluetooth so i can listen to music on my computer wirelessly buy it gives me the same error message
    That's an entirely different issue, unrelated to your iOS devices.

  • I got error 3295 when doing software update to 4.3.4 on my iphone4.. can some one tell me how skip this error?? I'm new to apple products..!?

    I got error 3295 when doing software update to 4.3.4 on my iphone4.. can some one tell me how skip this error?? I'm new to apple products..!

    anyone????

  • God morning can some  one tell me how to delete app from the iphone4?

    cAN SOME ONE TELL ME HOW TO DELETE APP FORM THE IPHONE4??

    If it is an App you have Downloaded and there is no X when it Wiggles...
    Perhaps this Assistant can Help you:
    http://www.apple.com/support/iphone/assistant/application/

  • Please can some one tell me how I can remove an ex boyfriends account from my iPad ? I want it update my updates but his email address always comes up and not mine

    Please can some one tell me how I can remove an ex boyfriends account from my iPad ? I want it update my updates but his email address always comes up and not mine

    Press and hold any of the apps on your iPad's homescreen and after a couple of seconds or so they should start to shake. Then press the 'x' in the top left corner to delete the ones that you don't want, and when you've finished deleting press the home button so as to stop the shaking. If you don't get the 'x' on any of the apps that you've downloaded then check that Settings > General > Restrictions > Deleting Apps isn't set 'off'.
    Note that deleting an app will delete all of its content as well

  • I have a brand new hp officejet 6700 premium e-all-in-one printer but my macbook pro is not detecting the printer to even install it or make a print can some one tell me if it is a problem with the printer or the macbook pro?

    can some one help me with the question ..

    no not at all..it was just tested if it was being detected on a windows os..it did..i am doubting either it is a problem with the router or the macbook pro....but earlier it did connect well to a hp officejet pro 8600 e-all-in-one printer over a different network(at someone else's house)...

  • Please can some-one tell me where to find the price differences between the ACA and ACE exams.

    Please can someone tell me the price difference (in ZAR) between the ACE and ACA exams.

    Why did you post this in the forum for Adobe Reader?

  • Can some one tell me how to get this imessage (i think thats what it is they are in blue) off my flippin phone because they are going to other ppl as well as ppl intended and i keep recieving msgs from randoms grrr please help

    i recently went from a iphone 3 to a 4 and when i send messages they are going to other ppl as well as the ppl they are intended for this did happen once with the iphone 3 but now its all the time i have been in settings but it's not high lighted so dont know how to get the **** thing off so i can just send normal msgs, please advise 

    i didnt have any on but i disabled it then enabled lol dunno how but i have done it i think thanks for your help there is tooooo many settings on the phone for me i was ok with the 3GS just flicking through settings again and my face time as dissapeared lol any ideas

  • I have 1.7 g of space left on my Ipad but the app store will not let me download garage band on to my iPad with is only 808mb can some one tell why this is happening. Thanks

    Loads of space but not letting me download garage band on to my iPad and comes up with pop up saying not anough space on the iPad

    When the app is downloaded it will expand as all app downloads do. You are downloading a "compressed installer" in a manner of speaking. When the app expands it will be larger than the space that you have left on the device.
    App downloads on a computer work the same way,

  • My i tunes account for my pc and i phone wont let me update my apps or download any new ones can some one tell me why?

    my i tunes account for both my pc and i phone wont let me update or download any apps.

    no none errors it started after i installed the new ios 5.1 on my i phone i wait ages ans it says cannot conect to the i tunes store. and on the pc when i go to update them it says service timed out after about ten mins of waiting

  • When I open my safari it will no longer go directly to my yahoo home page, says..Safari cannot open page because too many redirects occurred,  Can some one tell me how to fix this, I have tried bookmark but won't open from there.

    when I open my safari it will no longer go directly to my yahoo home page, says.. Safari cannot open page because too many redirects accured, how do I fix this.

    Clear the cache in Safari and have another try
    Cheers!

  • How can some one, hearing my call- receiving?

    I have a central phone box in my office, and two phone (panasonic secretory) phones, in my office. I'm almost sure that someones can hear my voice in the office, or hearing phone calls, as voicemail, or email, or sms,... I don't know. As i have apple p.c, and Iphone, and Ipad one, and Ipad Air, so my everything is Apple, and Macintouch system, and earlier I used LAN at my office to connect these all, plus my Printer including Scanner and Fax, plus one Camera for Security conected to a DVR for recording, and a 38 inches LED connected to camera too, so at the moment I feel, and sure someones are listening or even may be watching me at the office, is there anyone who could help me, or suggesting me to do something acording my problem? I really apreciate.

    martyjones wrote:
     i have got a new playbook and the software is os 2.1.01 
    Are you sure that's the version?
    martyjones wrote:
    Hi all can some one tell my how I get android apps on my playbook 
    Read here: How To Sideload Android Apps On The BlackBerry PlayBook OS 2.0
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Can some one explain each line of this abap code

    Hi..
      I got this code from a document, where they try to add account group (LFA1-KTOKK) to 0VENDOR_ATTR. I have no idea of ABAP syntax. Can some one tell me the meaning of each line of code.
    Tables:  LFA1.          "vendor master data table
    data:    l_tabix      like sy-tabix.
    case i_CHABASNM.
    *Enhancement of Vendor Master Record
         WHEN '0VENDOR'.
           case i_datasource.
             WHEN '0VENDOR_ATTR'.
               data:  l_s_BIW_LFA1_S like BIW_LFA1_S.
               loop at i_t_data into l_s_BIW_LFA1_S.
                 l_tabix = sy-tabix.
                 select single * from lfa1 where LIFNR = l_s_BIW_LFA1_S-LIFNR.
                 if sy-subrc = 0.
                   l_s_BIW_lfa1_s-ZZacctgrp = lfa1-ktokk.
                   modify i_t_data from l_s_BIW_lfa1_s index l_tabix.
                 endif.
               endloop.
           endcase.
       endcase.
    Thanks in advance.

    Hi
    Tables: LFA1. "vendor master data table
    <b>"here by saying Tables they have delcared the LFA1 table for further use in the program"</b>data: l_tabix like sy-tabix.
    <b>"here they have defined own table index by copying the structure of system index"</b>case i_CHABASNM.
    <b>"when character"</b>
    *Enhancement of Vendor Master Record
    WHEN '0VENDOR'.
    <b>"here it says that its 0vendor"</b>case i_datasource.
    <b>"when this datasource"</b>
    WHEN '0VENDOR_ATTR'.
    <b>"when datasource 0vendor_attr"</b>
    data: l_s_BIW_LFA1_S like BIW_LFA1_S.
    <b>"here we are declaring an internal table like BW internal table"</b>loop at i_t_data into l_s_BIW_LFA1_S.
    <b>"here looping at i_t_data table data into l_s_BIW_LFA1_S".</b>l_tabix = sy-tabix.
    <b>"here we are saying that our defined table index is equal to system index"</b>select single * from lfa1 where LIFNR = l_s_BIW_LFA1_S-LIFNR.
    <b>"selecting single rows from table lfa1 where lifnr is equal to l_s_biw_lfa1 field s-lifnr"</b>
    if sy-subrc = 0.
    <b>"if system field returns 0 that means the above line has been executed"</b>
    l_s_BIW_lfa1_s-ZZacctgrp = lfa1-ktokk.
    "internal table field is equal to lfa1 field."
    modify i_t_data from l_s_BIW_lfa1_s index l_tabix.
    <b>"changing the internal table data as per i_t_data"</b>endif.
    endloop.
    endcase.
    endcase.
    THIS IS MY UNDERSTANDING PLEASE KINDLY CORRECT ME IF I AM WRONG.
    thanks
    harish

  • In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    If the SIM is out of your phone, find my phone needs a data connection, so could use wifi - IF in range of a wifi and one that it can join (ie. a known network or one that is wholly open so no login required).  Your phone could also simple be turned off, so not findable, or it may have been restored (plugged into iTunes and restored as new) again, making it permanently unfindable.  Honestly, for someone stealing an iPhone, this is likely the first thing they do - restore as new and it is theirs forever.
    Find my iPhone is tied to the users iCloud account - the find function is part of the iCloud account's services and it communicates with the iCloud servers over a data connection - either wifi or 3G.
    Have you set up your iCloud account on your replacement phone, and is it working properly on that phone?

Maybe you are looking for

  • Disk Utility + Disk Warrior

    I recently purchased DiskWarrior as I though it would be able to awaken my currently deceased Firewire Harddrive. Sadly it did not but after installing I ran the Disk Utility "Verify Disk Permissions" then "repaired the disk permissions" I then Veryi

  • How to connect to internet in solaris 11

    Hi All, I am a oracle DBA, not much knowledge of solaris. To install missing packages I need to connect my Solaris 11 box to internet. Data centre guys have provided me 1 proxy server IP address for LAN and a Port number. But i am not sure where to u

  • Is there a Cubase-style GM Drum Map in Logic?

    Hi! I've been really happy about choosing Logic, but I must admit that I'm almost envious to my friend who's using Cubase. Simply for the reason that I haven't found an equally effortless way to create drum beats as the GM mode in Cubase. The ability

  • TextField Focus

    Hello there, I am new to AS3 and trying to figure out how to set a focus to a textfield on the stage. I found out that if I use stage.focus = tf; then the tf get the focus and it does, when I type letters they go directly to this textfield. Problems

  • Need to set iTunes proxy setting without changing IE proxy info

    I would like a way to edit the iTunes user preferences to use a different proxy for my iTunes on Windows client than I am required to use for my other Internet settings. Please advise, thanks, Greg