Different result when using FOR UPDATE [message #663498] |
Tue, 06 June 2017 08:31 |
|
hundsmiachn
Messages: 2 Registered: June 2017
|
Junior Member |
|
|
Hi
I have a strange problem, maybe someone can help me:
Following Statement:
SELECT ( SELECT TABLE1.JANEIN FROM TABLE1 T1 WHERE TOURP.FK1 = T1.PK ) AS RESULT
FROM TOURP
WHERE TOURP.TOURNR = 'FM0000000FM'
FOR UPDATE OF TOURP.TOURPNR NOWAIT;
The RESULT has a constraint and can either be 'J' or 'N'. The strange thing now is that I get a 'J' if I dont use the "FOR UPDATE NOWAIT" and a 'N' when I use it. ('N' is the default value)
Could anybody explain to me why this can happen, should the result not be the same, if I lock the data or not ??
thanks in advance
regards
Erich
|
|
|
|
|
|
Re: Different result when using FOR UPDATE [message #663505 is a reply to message #663498] |
Tue, 06 June 2017 09:56 |
|
Michel Cadot
Messages: 68665 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
hundsmiachn wrote on Tue, 06 June 2017 15:31...
SELECT ( SELECT TABLE1.JANEIN FROM TABLE1 T1 WHERE TOURP.FK1 = T1.PK ) AS RESULT
FROM TOURP
WHERE TOURP.TOURNR = 'FM0000000FM'
FOR UPDATE OF TOURP.TOURPNR NOWAIT;
...
NEVER use SELECT in SELECT clause unless you are an expert in SQL.
First of all, rewrite your query then we can see if you have an actual problem.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
|
|
|