![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've only just come across this possible SQL bug and was wondering why this SQL returns a result? I got it through an email and had to change it to Oracle's syntax as the original used the concat operator of + and it didn't use DUAL. -- Note the spaces after 'WHY * ' select * '<'||Y||'>', Y from * ( select 'WHY * ' Y from dual) x where * Y = 'WHY' ; P.S. Yes I know that 9i is well and truly obsolete ![]() |
#3
| |||
| |||
|
|
Same in 10gr2. *And I suspect it'd be the same in 11g. I think you've been trapped by implicit conversion in Oracle, which doesn't happen in the original MSSQL. |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I've only just come across this possible SQL bug and was wondering why this SQL returns a result? I got it through an email and had to change it to Oracle's syntax as the original used the concat operator of + and it didn't use DUAL. -- Note the spaces after 'WHY ' select '<'||Y||'>', Y from ( select 'WHY ' Y from dual) x where Y = 'WHY' ; P.S. Yes I know that 9i is well and truly obsolete ![]() |
#6
| |||
| |||
|
|
select 'Why is this displayed?' from DUAL where 'WHY ' = 'WHY' ; |
#7
| |||
| |||
|
|
On Feb 10, 10:34 am, Noons<wizofo... (AT) gmail (DOT) com> wrote: Same in 10gr2. And I suspect it'd be the same in 11g. I think you've been trapped by implicit conversion in Oracle, which doesn't happen in the original MSSQL. But there is no conversion going on. It is looking for an exact match. Also, you can see that the spaces are still present in the output. The result displayed, 'WHY ', does not equal 'WHY'. |
#8
| |||
| |||
|
|
Someone else may be able to confirm that this is an acceptable interpretation of the ANSI SQL99 standard for the comparison of CHAR elements of unequal length where trailing whitespace only occurs. Oracle seems to default strings in where clauses as CHAR. The same behaviour does not happen for VARCHAR or VARCHAR2 elements, at least in 11.2. |
#9
| |||
| |||
|
|
Geoff Muldoon wrote,on my timestamp of 10/02/2011 4:54 PM: Someone else may be able to confirm that this is an acceptable interpretation of the ANSI SQL99 standard for the comparison of CHAR elements of unequal length where trailing whitespace only occurs. Oracle seems to default strings in where clauses as CHAR. The same behaviour does not happen for VARCHAR or VARCHAR2 elements, at least in 11.2. Actually, if someone read the manual paragraph I pointed out, it'd be very clear what is going on. *It's got nothing to do with SQL99. |
#10
| |||
| |||
|
|
Geoff Muldoon wrote,on my timestamp of 10/02/2011 4:54 PM: Someone else may be able to confirm that this is an acceptable interpretation of the ANSI SQL99 standard for the comparison of CHAR elements of unequal length where trailing whitespace only occurs. Oracle seems to default strings in where clauses as CHAR. The same behaviour does not happen for VARCHAR or VARCHAR2 elements, at least in 11.2. Actually, if someone read the manual paragraph I pointed out, it'd be very clear what is going on. It's got nothing to do with SQL99. |
![]() |
| Thread Tools | |
| Display Modes | |
| |