Solved

SQL Store Procedure Oracle Developer, # between characters

Posted on 2014-03-12
5
549 Views
Last Modified: 2014-03-13
I have a field with numbers separated by ":" the problem is that I would it also contains other numbers.  I need just the 15 digit numbers within the semi colons.  An example of what is in the field is  :1571144410824900.000000:  I just need the 1571144410824900, the 16 digit number.  A field might have :1312710607045440.000000:1571144410824900.000000: but I just need the 16 digit numbers before the semi colons.  I main will be only one 16 digit number but I am just.  Can you help.  The Name of the field is Booklist.
0
Comment
Question by:trinisunset
[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
5 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 39925653
The question is in Oracle and SQL Server 2005. What is your database?
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 39926087
>> A field might have :1312710607045440.000000:1571144410824900.000000: but I just need the 16 digit numbers before the semi colons.

Which one is that? they are both between semicolons and hence both before at least one semicolon.

Also, your description says 15 digits and 16 digits but your values are 22 digits.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 39926096
Assuming you want the first 16 digit (but possibly followed by zeros) value that is between semicolons then try this on Oracle 11.2 or higher.


REGEXP_SUBSTR(
           booklist,
           ':([0-9]{16})(\.0*)?:',
           1,
           1,
           NULL,
           1
       )

If your version is 10.1 or higher you can nest the regexp inside a substr to get the subexpression

SUBSTR(REGEXP_SUBSTR(booklist, ':([0-9]{16})(\.0*)?:'), 2, 16)
0
 

Author Closing Comment

by:trinisunset
ID: 39926248
Thank you this SUBSTR(REGEXP_SUBSTR(booklist, ':([0-9]{16})(\.0*)?:'), 2, 16)  worked.  Thank you, thank you!!!!
0

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.
Suggested Courses

626 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