Solved

Query substr

Posted on 2008-06-26
3
573 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
  • 2
3 Comments
 
LVL 73

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 73

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 117
How to free up undo space? 3 39
Shredding xml into an oracle 11g Database 2 42
clob to char in oracle 3 34
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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 video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now