Solved

Query substr

Posted on 2008-06-26
3
578 Views
Last Modified: 2013-12-07
Can someone explain what this line below is accomplishing. I am fairly new to PLSQL.  

substr(max((lpad(percent,10,'0') | | line_num)),11,6)
0
Comment
Question by:Medicine1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 250 total points
ID: 21876184
assuming percent and line_num are columns in a table it's something like this.

given a percent like 17, pad it with zeroes out to 10 characters.

0000000017
then append the line_num column to it.  so if Line_num is 8 then you'll get a string

00000000178

do that for every column and find the maximum value of all of them.
so

000001689156 will be greate than 00000000178


then with that maxium value (in this case 000001689156)  start with the 11th charcter and read
forward 6 characters (or until you run out of characters) and return that.

so...  given 000001689156
that would return "6"

if you had 0000123456987654321  you would get 987654





0
 

Author Comment

by:Medicine1
ID: 21876379
Is the | | (bars) combining the numbers?
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 21876915
yes, that's the string concatenation symbol
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question