Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9255205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:39:47+00:00 2026-06-18T11:39:47+00:00

I am trying to take a notes field that is just a big block

  • 0

I am trying to take a notes field that is just a big block of text, sample data is below as if I were inserting it into a table.

create table test_table
(
job_number number,
notes varchar2(4000)
)

insert into test_table (job_number,notes)
values (12345,1022089483 notes notes notes notes 1022094450 notes notes notes notes 1022095218 notes notes notes notes)

I need to parse it out so there is a separate record for each notes entry (the 10 digit numbers leading the notes are unix timestamps). so if i were to export to pipe delimited it would look like this:

job_number|notes

12345|1022089483 notes notes notes notes

12345|1022094450 notes notes notes notes

12345|1022095218 notes notes notes notes

I really hope this makes sense. I appreciate any insight.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:39:49+00:00Added an answer on June 18, 2026 at 11:39 am

    a few ways of doing this:

    SQL> insert into test_table (job_number,notes)
      2  values (12345,'1022089483 notes notes notes notes 1022094450 notes notes notes notes 1022095218 notes notes notes notes');
    
    1 row created.
    
    SQL> insert into test_table (job_number,notes)
      2  values (12346,'1022089483 notes notes notes notes 1022094450 foo 1022095218 test notes 1022493228 the answer is 42');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    

    note: i’m using [0-9]{10} as my regex to determine the note (ie any 10 digit number is considered the start of the note).

    first up, we can take the approach of calculating the max number of notes in any given row, and then do a cartesian join with that number of rows. then filter out each note:

    SQL> with data
      2  as (select job_number, notes,
      3            (length(notes)-length(regexp_replace(notes, '[0-9]{10}', null)))/10 num_of_notes
      4        from test_table t)
      5  select job_number,
      6         substr(d.notes, regexp_instr(d.notes, '[0-9]{10}', 1, rn.l),
      7                       regexp_instr(d.notes||' 0000000000', '[0-9]{10}', 1, rn.l+1)
      8                       -regexp_instr(d.notes, '[0-9]{10}', 1, rn.l) -1
      9               ) note
     10    from data d
     11         cross join (select rownum l
     12                      from dual
     13                    connect by level <= (select max(num_of_notes)
     14                                           from data)) rn
     15   where rn.l <= d.num_of_notes
     16   order by job_number, rn.l;
    
    JOB_NUMBER NOTE
    ---------- --------------------------------------------------
         12345 1022089483 notes notes notes notes
         12345 1022094450 notes notes notes notes
         12345 1022095218 notes notes notes notes
         12346 1022089483 notes notes notes notes
         12346 1022094450 foo
         12346 1022095218 test notes
         12346 1022493228 the answer is 42
    
    7 rows selected.
    

    that is ok as long as the number of notes is generally the same (the bigger the differences
    the worse this scales, as we are doing a lot of recursive lookups).

    in 11g we could use a resursive factored sub query to do the same thing as above, but doesn’t do extra looping:

    SQL> with data (job_number, notes, note, num_of_notes, iter)
      2  as (select job_number, notes,
      3             substr(notes, regexp_instr(notes, '[0-9]{10}', 1, 1),
      4                    regexp_instr(notes||' 0000000000', '[0-9]{10}', 1, 2)
      5                    -regexp_instr(notes, '[0-9]{10}', 1, 1) -1
      6                  ),
      7             (length(notes)-length(regexp_replace(notes, '[0-9]{10}', null)))/10 num_of_notes,
      8             1
      9        from test_table
     10      union all
     11     select job_number, notes,
     12             substr(notes, regexp_instr(notes, '[0-9]{10}', 1, iter+1),
     13                    regexp_instr(notes||' 0000000000', '[0-9]{10}', 1, iter+2)
     14                    -regexp_instr(notes, '[0-9]{10}', 1, iter+1) -1
     15                  ),
     16             num_of_notes, iter + 1
     17       from data
     18      where substr(notes, regexp_instr(notes, '[0-9]{10}', 1, iter+1),
     19                    regexp_instr(notes||' 0000000000', '[0-9]{10}', 1, iter+2)
     20                    -regexp_instr(notes, '[0-9]{10}', 1, iter+1) -1
     21                  ) is not null
     22    )
     23  select job_number, note
     24    from data
     25  order by job_number, iter;
    
    JOB_NUMBER NOTE
    ---------- --------------------------------------------------
         12345 1022089483 notes notes notes notes
         12345 1022094450 notes notes notes notes
         12345 1022095218 notes notes notes notes
         12346 1022089483 notes notes notes notes
         12346 1022094450 foo
         12346 1022095218 test notes
         12346 1022493228 the answer is 42
    
    7 rows selected.
    

    or from 10g onwards we could use the model clause to make up rows:

    SQL> with data as (select job_number, notes,
      2                       (length(notes)-length(regexp_replace(notes, '[0-9]{10}', null)))/10 num_of_notes
      3                  from test_table)
      4  select job_number, note
      5    from data
      6  model
      7  partition by (job_number)
      8  dimension by (1 as i)
      9  measures (notes, num_of_notes, cast(null as varchar2(4000)) note)
     10  rules
     11  (
     12    note[for i from 1 to num_of_notes[1] increment 1]
     13      = substr(notes[1],
     14               regexp_instr(notes[1], '[0-9]{10}', 1, cv(i)),
     15               regexp_instr(notes[1]||' 0000000000', '[0-9]{10}', 1, cv(i)+1)
     16               -regexp_instr(notes[1], '[0-9]{10}', 1, cv(i)) -1
     17              )
     18  )
     19  order by job_number, i;
    
    JOB_NUMBER NOTE
    ---------- --------------------------------------------------
         12345 1022089483 notes notes notes notes
         12345 1022094450 notes notes notes notes
         12345 1022095218 notes notes notes notes
         12346 1022089483 notes notes notes notes
         12346 1022094450 foo
         12346 1022095218 test notes
         12346 1022493228 the answer is 42
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the maximum value of an integer field in a table.
I'm trying to work a little macro that will format some data so that
I am trying to parse a table in the form of a text file
I'm trying to create a trigger on my table, so that when I insert
using LyX I'm trying to convert the comments into marginal notes. I tried several
I am trying to build a web application that will take an scan paper
I'm trying to subset a block of data for a year's time period. There
I'm trying to take a {variable} string and cut it down for entry into
I have a datagridview with 9 columns. I am simply trying take the value
trying to take this content: <div class=content>one,two,three</div> <div class=content>four,five,six</div> <div class=content>seven,eight,nine</div> and .split and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.