|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
The first 2 queries do not behave identically while the remaining 2 do when we input the following values for input parameters:
&FIR=2 &SEC=4 why is it so ? the culprit seems the OR condition which seems to behave in a strange manner on doing a comparison with a SELECT ( ie. when a cursor comes into picture ) could you please tell me why ???? ----------------------------------------------- select 'SOMETHING' from dual where (&FIR = 1 OR &FIR=( SELECT 2 FROM DUAL )) AND (&SEC = 3 ) ------------------------------------------------ select 'SOMETHING' from dual where (&FIR = 1 OR &FIR= 2 ) AND (&SEC = 3 ) ---------------------------------------------------- select 'SOMETHING' from dual where ( &FIR=( SELECT 2 FROM DUAL )) AND (&SEC = 3 ) ------------------------------------------------ select 'SOMETHING' from dual where ( &FIR= 2 ) AND (&SEC = 3 ) -------------------- This was checked in the SQL environment provided by PL/SQL Developer for Oracle 9i Last edited by jj_oracle : May 10th, 2004 at 12:52 PM. Reason: wish to mention the database with which this was checked |
|
#2
|
|||
|
|||
|
Suppose to produce the same result. Actually what is you first two queries are doing. Print the string 'Something' When &FIR either One (1) or two (2) but &SEC must be equal to three (3), second query is produce the same result as well. But the last two queries print the string 'Something' when &FIR must be equal to 2 and &SEC equal to three (3).
|
|
#3
|
|||
|
|||
|
Quote:
I ran the queries in Oracle 9i - PL/SQL Developer environment: One would assume that the laws of Boolean Algebra would hold and that if the expression succeeding the AND part were false, nothing would be printed however this happens only in the second case and not the first: if I input parameter values as &FIR=2 , &SEC=4 the first query returns the string 'SOMETHING' while the second query does not retrieve anything, and neither does the third or the fourth, for these values |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > ORroneous Behaviour in SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|