Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how does pl/sql handle <,>, = operations on strings 2

Status
Not open for further replies.

FatalExceptionError

Technical User
Joined
Apr 10, 2001
Messages
100
Location
US
i need to know how a a compiler handles logical operations like this specifically for strings. Does it do it based on the ascii value or what.
ie if i have a statement like this
Code:
if some_string >= some_constant_string
with some_string = '20020411'
and some_constant_string = '20020101'
what would it return
 
I suppose you're trying to compare 2 dates represented as strings. As for numbers Oracle uses ascii codes so '20020411'>'20020101' because '4' is obviously greater than '1'. As for other characters you may use ALTER SESSION to change NLS_SORT parameter to perform either binary or lexical comparison.

If my asumption regarding dates is correct I would recommend you to compare dates by using to_date function.
 
The ordering is based on the ASCII value of the characters.

'20020411' >= '20020101' => TRUE

The comparison takes place from left to right.
Since 4 has (in '200204..') higher ascii value than 1 (in '200201..') , the above expr. returns TRUE.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top