Subject | Re: SQL needs to be reviewd and some questions: |
---|---|
Author | Adam |
Post date | 2005-01-21T21:06:54Z |
>if
> Q: Could I use SELECT UPDATE LOCK syntax to replace the above code?
> so how to do it and how to do unlocking?update DIVISION set
>
LOCKED = :PostBy
where ID = :DivisionID;
You do not need the null test, this will raise an exception if
another transaction is using that ID.
> 2)Q: How to use "WHEN SQLCODE xxxx DO BEGIN ... END", Do I have toput
> each WHEN after update/insert/delete statement, or just one WHENIt is sort of like delphi.
> statement at the end of the procedure(more simailiar with the Delphi
> try ... except ... end;)?
1) you need to put a begin where you would have put a try in delphi,
and then an end exactly where you would put it in delphi.
2) You put in the:
WHEN SQLCODE xxxx DO BEGIN ... END
just above the end you added in step 1.
When is equivalent to the except statement in delphi, it absorbs the
exception, and the Exception keyword is equivalent to raise.
> 3)Q: Where can I get all the SQLCODE value, e.g. what's the valuefor
> Deadlock sqlcode, any doc I can take a look at?The file you are looking for is langref.pdf (try www.ibphoenix.com).
You could always just open two isql windows and update the same
record without committing simultaneously, and you will get that error.
The lock is automatically released when you commit or rollback your
transaction.