Home » SQL & PL/SQL » SQL & PL/SQL » Quick question about comparisons.
Quick question about comparisons. [message #214621] Wed, 17 January 2007 05:07 Go to next message
ziggy25
Messages: 206
Registered: July 2005
Senior Member
Im looking at a cursor that has this as part of its condition
  AND SUBSTR(scra.orig_system_reference,4 ,10) = orig_ref_in || 'S'
  

The data this condition will be applied for looks something like this

scra.orig_system_reference
---------------------------
SUKAAB
SUKAAC
SUKAAD
SUKAAG
SUKGBS


orig_ref_in is something like AAB, AAC or GBS. I cant figure out what the ||S is doing in the cursor. I have looked at the data and none of it ends with 'S'.

Why does the cursor pick the correct row even though there is no row that ends in 'S'? Is it possible that the concatenation of orig_ref_inand 'S' happens after the comparison has taken place? i.e. it does this first
SUBSTR(scra.orig_system_reference,4 ,10) = orig_ref_in 


then

orig_ref_in || 'S'


Thanks in advance.
Re: Quick question about comparisons. [message #214629 is a reply to message #214621] Wed, 17 January 2007 05:47 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
In the code you've posted, the concatenation will definitely take place before the comparison.
Re: Quick question about comparisons. [message #214631 is a reply to message #214621] Wed, 17 January 2007 05:49 Go to previous messageGo to next message
Kprattip
Messages: 15
Registered: January 2006
Location: INDIA
Junior Member
Its never done like that, as u told.

First both the sides get executed left to right and then comparison starts.

example:
--------

SQL> select *
  2  from kiran;

no rows selected

SQL> insert into kiran values ('ABCD');

1 row created.

SQL> select *
  2  from kiran;

TEXT
---------------------------------------------
ABCD


SQL> select *
  2    from kiran
  3  where substr('SUKAAB',4,10) = 'AAB'||'S';

no rows selected

SQL> select substr('SUKAAB',4,10) from kiran;

SUB
---
AAB

SQL> select 'AAB'||'S' from dual;

'AAB
----
AABS


Hope its clear.

Kiran Prattipati


[Updated on: Fri, 26 October 2007 06:09] by Moderator

Report message to a moderator

Re: Quick question about comparisons. [message #214634 is a reply to message #214631] Wed, 17 January 2007 05:54 Go to previous messageGo to next message
ziggy25
Messages: 206
Registered: July 2005
Senior Member
Thanks that makes sense. I guess ill have to find out what the 'S' is doing in the code.

Thanks
Re: Quick question about comparisons. [message #214638 is a reply to message #214634] Wed, 17 January 2007 06:08 Go to previous message
ziggy25
Messages: 206
Registered: July 2005
Senior Member
Found it.. S does exist on some of the records. Laughing

Thanks for the help.
Previous Topic: Tree Walking
Next Topic: Date Format
Goto Forum:
  


Current Time: Wed Dec 07 20:35:56 CST 2016

Total time taken to generate the page: 0.05450 seconds