Hi Phil, I guess the lock-option "exclusive" is what You're looking for.
<single_select_statement> ::= SELECT [<distinct_spec>] <select_column>,... INTO <parameter_spec>,... FROM <from_table_spec>,... [<where_clause>] [<group_clause>] [<having_clause>] [<lock_option>] where <lock_option> ::= WITH LOCK [(IGNORE)|(NOWAIT)] [EXCLUSIVE|OPTIMISTIC] [ISOLATION LEVEL <unsigned_integer>] So do your query like this: SELECT * FROM benutzer WITH LOCK EXCLUSIVE; Regards, Michael Am Dienstag, 21. Oktober 2003 09:34 schrieb [EMAIL PROTECTED]: > Hi, > > well the problem is that these unique numbers(aktenzeichen) are not > generated by me. They are in the DB (not my problem how they go in there). > So when the systems receives an email, this email needs one of these > numbers(aktenzeichen). So i need to get the umber and delete that number > and make sure that no other process that might me running at the same time, > gets the same number! > > any ideas?? > > > [EMAIL PROTECTED] wrote: > > > Hi. > > > I am having problems with LOCK and JAVA. > > > > > > I need to make sure that no other Process is reading from a > > > table, because in that table are unique numbers. > > > So i want to lock the table, select a number(select * and > > > read the first numer), delete this number and release. > > > > No answer directly to your question, but another idea. > > What do you want to do, have a unique (the next) number for the next > > insert? Why don't you use sequences resp. DEFAULT SERIAL resp. the > > datatype SERIAL as described here > > http://www.sapdb.org/7.4/how_tos/numbergen/howto_producenumgen_eng.htm > > and discussed in this list several times. > > > > Maybe this could solve the problem you want to handle with your > > lock/select/unlock- sequence ... > > > > Elke > > SAP Labs Berlin > > > > > But somehow the lock is not working. > > > Here is what I have tried: > > > > > > Connection con = getCon(); > > > Statement stmt = con.createStatement(); > > > stmt.execute("LOCK (NOWAIT) TABLE benutzer IN SHARE > > > MODE TABLE benutzer IN EXCLUSIVE MODE "); > > > System.out.println("before insert"); > > > stmt.execute("INSERT into test (name) values ('hallo')"); > > > System.out.println("after insert"); > > > > > > Thread.sleep(10000); > > > > > > stmt.execute("UNLOCK TABLE benutzer IN SHARE MODE TABLE > > > benutzer IN EXCLUSIVE MODE "); > > > //resultSet.close(); > > > stmt.close(); > > > con.close(); > > > System.out.println("done"); > > > > > > > > > I am starting this twice and both tell me instantly before > > > insert, after insert. > > > AS I understand lock, the first task should tell me that, but > > > the second should only tell before! > > > > > > What am I doing wrong? > > > > > > How can I prevent that a unique number is read twice by > > > different task? > > > > > > Please help! > > > > > > Phil > > > > > > > > > -- > > > MaxDB Discussion Mailing List > > > For list archives: http://lists.mysql.com/maxdb > > > To unsubscribe: > > > > http://lists.mysql.com/[EMAIL PROTECTED] -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
