Solved

How can I grab this in oracle in SQL

Posted on 2015-02-21
6
144 Views
Last Modified: 2015-04-02
Hi,

here is sqlfidlle

http://sqlfiddle.com/#!4/8089b/1

I would like to get the result below out of that...

fist  |  second
100  | 200
101  | 201
102  | 202
103  | 203
104  | 204
105  | 205

regards
0
Comment
Question by:hi4ppl
[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
6 Comments
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40623085
What have you tried already, besides 'select * from ....' ?
0
 
LVL 1

Author Comment

by:hi4ppl
ID: 40623119
Hi,

I did try select regexp_substr(thatfield,'[^,]+]',2,2) as a table1 but it only pick if it will be the start if it's at end it won't pick it ...
0
 
LVL 32

Expert Comment

by:awking00
ID: 40623177
select
substr(thatfield,instr(thatfield,'{name') + 6,3) as first,
substr(thatfield,instr(thatfield,'{name') + 10,3) as second
from table1;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Assisted Solution

by:awking00
awking00 earned 250 total points
ID: 40623190
With regexp -
select ltrim(regexp_substr(thatfield,',[^,]+',instr(thatfield,'{name')),',') as first,
ltrim(regexp_substr(thatfield,',[^}]+',instr(thatfield,'{name') + 6),',') as second
from table1;
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 250 total points
ID: 40623389
Already some replies above but  I'd first look for that part that contains the numbers:
select regexp_substr (ThatField,'{name,\d{3},\d{3}}') from Table1;

Open in new window


which would result in:
{name,100,200}
{name,101,201}
{name,102,202}
{name,103,203}
{name,104,204}
{name,105,205}

and then 'translate' using regexp_replace it the way you want it:
select
regexp_replace((regexp_substr (ThatField,'{name,\d{3},\d{3}}')),
'({name,)(\d{3}),(\d{3})(})',
'\2|\3')
as "first|second"
from Table1;

Open in new window


(the regexp_replace is finding 4 patterns, I'm only printing 2 and 3 with a | in between)

This results in:

FIRST|SECOND
100|200
101|201
102|202
103|203
104|204
105|205
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40623449
will the "field" widths alter in the data? e.g.

THATFIELD
{blahblah,77100,6200}{secondname,200001}
{muchlongerstringinthislocationwithembeddednumbers123name,17801,201234}
{can spaces exist in this location - question to you,1941,51244}


when preparing sample data make sure it covers all situations (well, at least the most likely)
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

728 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