Home » RDBMS Server » Server Administration » Oracle-Sql
Oracle-Sql [message #370399] Mon, 20 September 1999 08:09 Go to next message
Walter
Messages: 15
Registered: September 1999
Junior Member
Sorting Problem with '+' and '-'.

If I create this table:

create table test (C1 varchar2(10));
create unique index test_index on test (c1);

insert into test (c1) values ('+2');
insert into test (c1) values ('-2');
insert into test (c1) values ('+1');
insert into test (c1) values ('-1');

select * from test order by c1;

The following listing shows the output:

C1
----------
+1
-1
+2
-2

How come????
Re: Oracle-Sql [message #370400 is a reply to message #370399] Mon, 20 September 1999 09:40 Go to previous messageGo to next message
m a sivan
Messages: 34
Registered: July 1999
Member
check up the dump and u will come to know the answer urself.. say

select dump(c1) from test..

now the soln..
since u have taken varchar... make it either number or if u know that u are only storing numbers
then change index to

create unique index test_index on test (to_number(c1));
Re: Oracle-Sql [message #370402 is a reply to message #370400] Mon, 20 September 1999 11:12 Go to previous messageGo to next message
Walter
Messages: 15
Registered: September 1999
Junior Member
Thank you - It's works with:

select * from test order by dump(c1)

But why this strange behavior ?
Re: Oracle-Sql [message #370403 is a reply to message #370402] Mon, 20 September 1999 13:22 Go to previous message
m a sivan
Messages: 34
Registered: July 1999
Member
Actually the field type is Varchar and thats why???

Thanks
Sivan
Previous Topic: Oracle API Urgent
Next Topic: Help me to Know About Rownum
Goto Forum:
  


Current Time: Tue Oct 20 10:10:48 CDT 2020