hehe prolly why I've never heard of it (don't use Oracle, lol).
Cheers for the correction ;o)
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
news:%23VqPpZ1gGHA.4712@TK2MSFTNGP05.phx.gbl...[color=blue]
> 'UPDATE FOR' is an Oracle DB statement. Apparently, it locks rows that are
> being updated.
>
> Bob Lehmann
>
> "Steven Burn" <somewhere@in-time.invalid> wrote in message
> news:O9hnho0gGHA.1208@TK2MSFTNGP02.phx.gbl...[color=green]
> > Last time I checked, "UPDATE FOR ..." was not a valid statement in an[/color][/color]
SQL[color=blue][color=green]
> > string .... it should instead be;
> >
> > sSQL = "UPDATE [TABLE_NAME] SET FIELD1 = '" & New_Value & "' etc
> > etc........."
> >
> > Not quite sure where the BeginTrans/RollbackTrans etc comes from as I've
> > never heard of them myself ......... but thats just me....
> >
> > As an additional FYI ..... you should NEVER EVER EVER EVER use "Select[/color][/color]
*"[color=blue][color=green]
> >
> >
http://aspfaq.com/show.asp?id=2096
> >
> > But the experts know best so I shall retire back to my lil' corner[/color]
> ........[color=green]
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> >
www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Steve" <javacc2@gmail.com> wrote in message
> > news:1148922567.715859.74620@j55g2000cwa.googlegro ups.com...[color=darkred]
> > > Anthony:
> > >
> > > I will use ASP approach without using stored procedure. What bothers[/color][/color][/color]
me[color=blue][color=green][color=darkred]
> > > is that there are 3 methods that perform 3 different transactions. Do
> > > you suggest I should put all 3 different transactions into a single
> > > method?
> > >
> > > In get_balance() method, I put SELECT...FOR UPDATE statement inside
> > > BeginTrans/RollbackTrans block instead of BeginTrans/CommitTrans,[/color][/color][/color]
since[color=blue][color=green][color=darkred]
> > > I think it just tries to lock the row and no updates happen in that
> > > get_balance() method. However, there will be table updates in
> > > tb_update() and tb_insert() methods. It seems to me that ASP requires
> > > BeginTrans method in order to use SELECT...FOR UPDATE statement, but I
> > > have no idea why. My understanding is that BeginTrans will open a
> > > nested transaction, but what is the rationale behind that?
> > >
> > > Another concern is that if I continue to use 3 separate methods, is it
> > > possible to have transactions happen in between method calls?
> > >
> > > > > Pseudocode
> > > > > ==========
> > > > > //1) call get_balance() method to perform select statement to get
> > > > > current_balance
> > > > > //some transaction happens here ????
> > > > > //2) call tb_update() method to perform update statement based on
> > > > > current_balance
> > > > > //some transaction happens here ????
> > > > > //3) call tb_insert() method to perform insert statement based on
> > > > > current_balance
> > > > >
> > > > > code fragment of get_balance() method:
> > > > > =====================================
> > > > > objConn.BeginTrans
> > > > > objRS.Open "SELECT * FROM EMP FOR UPDATE OF EMPNO", objConn,
> > > > > adOpenForwardOnly, adLockBatchOptimistic
> > > > > current_balance = objRS(0)
> > > > > objConn.RollbackTrans
> > >
> > > Again, pleae advise more and thanks for your suggestions and inputs.
> > >
> > > Steve.
> > >
> > >
> > > Anthony Jones wrote:
> > > > "Steve" <javacc2@gmail.com> wrote in message
> > > > news:1148522222.106038.102510@j73g2000cwa.googlegr oups.com...
> > > > > Basically below is what I am doing, and the interesting[/color][/color][/color]
observation[color=blue]
> is[color=green][color=darkred]
> > > > > that Oracle SELECT ... FOR UPDATE clause needs to use with
> > > > > objConn.BeginTrans method. I still don't understand what is the[/color]
> > reason.[color=darkred]
> > > > > Any ideas?
> > > > >
> > > > > Another concern is do you think it is possible another transaction[/color][/color]
> can[color=green][color=darkred]
> > > > > happen right after objConn.RollbackTrans (after step 1 & 2), since[/color][/color]
> the[color=green][color=darkred]
> > > > > lock has released? If this is the case, then current_balance may[/color][/color][/color]
not[color=blue][color=green]
> > be[color=darkred]
> > > > > updated when the application calls tb_update() and tb_insert()[/color]
> > methods.[color=darkred]
> > > > >
> > > > >
> > > > > Pseudocode
> > > > > ==========
> > > > > //1) call get_balance() method to perform select statement to get
> > > > > current_balance
> > > > > //some transaction happens here ????
> > > > > //2) call tb_update() method to perform update statement based on
> > > > > current_balance
> > > > > //some transaction happens here ????
> > > > > //3) call tb_insert() method to perform insert statement based on
> > > > > current_balance
> > > > >
> > > > > code fragment of get_balance() method:
> > > > > =====================================
> > > > > objConn.BeginTrans
> > > > > objRS.Open "SELECT * FROM EMP FOR UPDATE OF EMPNO", objConn,
> > > > > adOpenForwardOnly, adLockBatchOptimistic
> > > > > current_balance = objRS(0)
> > > > > objConn.RollbackTrans
> > > > >
> > > > >
> > > > >
> > > > > Please advise more. thanks!!!
> > > > >
> > > >
> > > > FOR UPDATE informs Oracle that the rows in the selected set are[/color][/color][/color]
about[color=blue]
> to[color=green]
> > be[color=darkred]
> > > > updated. It therefore will place a lock on them. For that lock to[/color][/color]
> have[color=green]
> > any[color=darkred]
> > > > meaning it needs to be made in the context of a transaction.
> > > >
> > > > The if you use the RollbackTrans call as it seems you are in the[/color][/color][/color]
code[color=blue][color=green]
> > above[color=darkred]
> > > > you might as well not bother with the transaction at all and drop[/color][/color][/color]
the[color=blue][color=green]
> > FOR[color=darkred]
> > > > UPDATE clause.
> > > >
> > > > The sequence you've outlined above should be protected by a[/color][/color]
> transaction.[color=green]
> > It[color=darkred]
> > > > would be best handled by an SP in ORACLE that does all the[/color][/color][/color]
transaction[color=blue][color=green][color=darkred]
> > > > management locally. If you must do it in ASP then you need a
> > > > BeginTrans/CommitTrans to span the whole sequence.
> > > >
> > > >
> > > > Bob, FOR UPDATE is the same as using the table hint SERIALIZABLE in[/color][/color]
> SQL[color=green][color=darkred]
> > > > Server.
> > >[/color]
> >
> >[/color]
>
>[/color]