I am trying to print a report using a table that has the primary key set up as an alphanumeric character. You can tyoe it as 'ABC123' or '123'. But this is giving me problems when trying to print a report based on this. If the user wants to print from '123-1' to '125-1' they are unable to do this because in between these numbers, because of the alphanumeric setup it would print 123-1,1230-1,124-1,1240-1,1241-1, 125-1. When all they want is 123-1,124-1,125-1.
Hope this makes sense. Here's is the code I am playing with.
SELECT A.SEGMENT1
FROM TABLE_NAME A
WHERE decode(rtrim(A.SEGMENT1,'0123456789'),NULL,to_number(A.SEGMENT1),-1)
BETWEEN
decode(rtrim(nvl(:P_req_num_from,A.SEGMENT1),'0123456789'),NULL,
to_CHAR(nvl(:P_req_num_from,A.SEGMENT1)),-1)
AND
decode(rtrim(nvl(:P_req_num_to,A.SEGMENT1),'0123456789'),NULL,
to_CHAR(nvl(:P_req_num_to,A.SEGMENT1 )),-1)
Any help is appreciated.
