Q
Problem solve Get help with specific problems with your technologies, process and projects.

# Alphanumeric page numbers, part 1

I currently have a VARCHAR2 column in an Oracle 8.1.7 database that I need to perform an alphanumeric sort on. We currently have page numbers stored in this column. The column data needs to be changed to allow decimal place page numbers and pages with alpha character. The page number have to be sorted like this:

``` 1 1a 1.1 1.11a 2.1 2.2b 2.2111b 3 3.05 3.5 4a 4.1
```

Quick guide to this expert response:

• Multi-column solution
• Single-column solution
• "Dewey decimal"
• Your page "numbers" are becoming multi-part objects: you should store them in the table as a multi-part object, either a user-defined type or as several columns.

Columns are like atoms: it takes some work to combine atoms into molecules, but that's not nearly as difficult as splitting them to get their component particles. In the same way, the coding effort and execution time needed to combine small columns into larger objects is less than that need to parse and break down large columns.

I'll give both a multi-column solution (which I recommend), and a single-column solution that will work in case you're already committed to storing the "numbers" in one big string.

In the sample data, "3.05" is shown as distinct from (and sorted before) "3.5", so I assume the numeric part is a true decimal, and that pages "1", "1.0" and "1.0000" are the same. Make sure all your users know this: the "Dewey decimal" system (where page "1.9" comes before "1.10", which is distinct from "1.100") may be more familiar. If the page numbers were Dewey decimals, I would recommend storing them in three columns: one integer for the numeric part before the decimal point, another integer for the numeric part after the decimal point, and an alphabetic part. But since, in this case, the numbers are true decimals, you can use two columns: a number and a string.

### Multi-column solution

The table definition should include something like:

``` , page_num NUMBER (16,8) , page_letter CHAR (1)
```

With this solution, sorting is really easy:

``` ORDER BY page_num , page_letter
```

To display the combined page number concisely:

``` SELECT TRIM (TO_CHAR (page_num)) || page_letter AS page_number ...
```

With this solution, you get a lot of validation for free. For example, bogus page numbers like "1.2.3" and "b1" simply won't go into the columns. Also, if a user does enter a page number like "1.0000" instead of "1", it won't matter: Oracle stores them the same way.

#### Start the conversation

Send me notifications when other members comment.

## SearchDataManagement

• ### Lessons learned from Credit Karma GraphQL architecture

Credit Karma's vice president of engineering explains why and how the personal finance service is using the GraphQL data query ...

• ### EnterpriseDB looks to grow market for PostgreSQL

Enterprises are increasingly using the open source PostgreSQL database. Read in this Q&A where the growth is coming from and how ...

• ### 3 of the top use cases for graph databases

Graph databases establish many unique relationships between data points. These unusual relationships are beneficial in many use ...

• ### Embedded BI software creates common ground for diverse analytics

Learn how embedding separate business intelligence capabilities into one application empowers users to drill down, access and ...

• ### Embedded BI and analytics apps speed workflows, insight access

Embedded BI is fast becoming a focal point for analytics uses as data analysts, developers and business users enjoy faster ...

• ### What Salesforce means for Tableau in the cloud

After the Salesforce acquisition, users have wondered about the future of Tableau in the cloud. Experts weigh in on how the ...

## SearchSAP

• ### Understand SAP ECC vs. HANA vs. S/4HANA vs. R/3

SAP ECC, HANA, S/4HANA and R/3 are all valuable tools in the IT world, but it's easy to get them confused. Learn about their ...

• ### 5 tips for a successful S/4HANA Cloud implementation

Moving to S/4HANA public cloud can help you save on IT maintenance and simplify real-time analysis. Here's a look at what you can...

• ### Take care of data before SAP S/4HANA migration

In this Q&A, Rajesh Rengarethinam of ERP security vendor Appsian discusses why reviewing data security and business processes are...

## SearchSQLServer

• ### SQL Server database design best practices and tips for DBAs

Good database design is a must to meet processing needs in SQL Server systems. In a webinar, consultant Koen Verbeeck offered ...

• ### SQL Server in Azure database choices and what they offer users

SQL Server databases can be moved to the Azure cloud in several different ways. Here's what you'll get from each of the options ...

• ### Using a LEFT OUTER JOIN vs. RIGHT OUTER JOIN in SQL

In this book excerpt, you'll learn LEFT OUTER JOIN vs. RIGHT OUTER JOIN techniques and find various examples for creating SQL ...

## TheServerSide.com

• ### CSS performance optimization in 5 easy steps

Here are five CSS performance tips to help you avoid website performance problems.

• ### Why the 8 Java primitive data types are not objects

What's the difference between Java primitive types and objects? To start, don't classify primitive types as objects. Let's ...

• ### A brief history of Java: How it forever changed programming

The Java programming language is an important tool in an application developer's quiver. But Java has also undergone many changes...

## SearchDataCenter

• ### Plan for a successful ITIL implementation

Corporate buy-in and training are essential for organizations that decide to adopt the ITIL framework. Admins should also help ...

• ### Learn the main Linux OS components

Linux is one operating choice to run on your infrastructure. Get started with these terms to discover how the OS works and how it...

• ### New Dell EMC PowerEdge servers are built for the rugged edge

New Dell Streaming Media Platform includes two small form factor PowerEdge servers and a Modular Data Center. Dell aims the ...

## SearchContentManagement

With new Google Drive integration, Adobe embeds free features for commenting and annotating PDFs inside Google Docs. Acrobat ...

• ### 4 benefits of business process automation

Companies are automating business processes to improve workflows and use technology effectively. Some benefits of BPA include ...

• ### Test yourself on the differences between SharePoint and OneDrive

Businesses use Microsoft SharePoint and OneDrive capabilities for a number of reasons. Test your knowledge on the differences ...

## SearchHRSoftware

• ### Trump's H-1B work visa actions disappoint ex-Disney workers

President Donald Trump arrived in office promising to reform the H-1B visa program. But his actions have fallen short of what ...

• ### How real-time analytics can benefit HR

For analytics to be truly useful, it must be embedded into user workflows. Learn how HR tools are incorporating such approaches ...

• ### Human vs. AI in recruiting: Why both matter

Recruiters may consider using both the human element and the data brought in by intelligent tools if it can help them make better...

Close