Re: multiple user question
Posted in 1996
This seems a little much to me for news group questions. It sounds like you realy need to both RTFM some more and read up extensively on multi user database programming. Here are some hints anyway. ccliu@csie.nctu.edu.tw (ccliu) wrote: :Hi, : Currently, our project is using single thread connect to DB. And we :are going to use 9 current connections . I know current users will :cause some problem the single connection won't has. As you are using Visual Basic it seems you mean 9 concurrent users each running single threaded applications. A sort of multithreading is possible in VB, but I assume that is not the real problem. :Can someong give me some advices when switch from single connection :to multiple connections. What important things I should be aware of. :Fro example, the Locking strategy, Application logical problem.... :Table INSERT/UPDATE/DELETE problem...... : :We are using INFORMIX-OnLine Version 7.13.UC1 :on HP-UX hag B.10.01 D 9000/856. :All codes are in SPL on Server side.. The users are using VB on client side. :My few notices: :1, I want user get share lock when SELECT. exclusive lock when : UPDATE/INSER/DELETE. I know SELECT.....FOR UPDATE, but only for ESQL/C, :the SPL can only use UPDATE CURSOR, and I don't know how to use it for :UPDATE/INSERT/DELETE? You have to turn on transactions (if you haven't allready done that) and get your locking that way. Everyting (except for plain select's) are then locked until you commit (or roll back). :2, Set table to Row lock is better than Page lock? If there is heavy locking activity on the table you get better concurrency (locking only of rows that actually need be locked). In other cases it may slow down your processing. :3, Set Lock Mode to wait or not wait? Depending on your application, but in most cases you would probably want wait x seconds. :4, At the transaction level, use "set transaction isolation level" or : use "set isolation level"? : Dirty read, Repeatable read or committed read? Entierly dependent on what you want to accomplish. :5, Some cases, :For Example, if one stored procedure use "new = MAX(fieldname) + 1;" statement, :if two users access this stored procedure at the same time, then one user of :them will get the wrong new value. How can I avoid this kind of things? Why would you want to do this at all? It sounds like a different design (serial columns in a table or possibly a separate table with one serial column to generate such numbers) would be better. :6, How to avoid deadlock? By programming intelligently. Allways lock for the minimum amount of time possible. Some locking involving multiple tables should allways be done in the same order. :Thanks. :please reply to sss@bart.sdit.com.tw : :Scott :sss@bart.sdit.com.tw Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org