Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Substring from Clob or Blob column

Posted on 2014-09-08
3
Medium Priority
?
387 Views
Last Modified: 2014-09-15
I have a table with blob column which stores all comments entered by users for particular assest (asset01)

CommentHeaderuser1 CommentDate2014-08-15-14.48.14.000000
CommentDateStageNbr20StageNbrCommentHeaderCommentBodytest 1 - first test CommentBody

CommentHeaderuser2 CommentDate2014-08-15-14.13.08.000000
CommentDateStageNbr20StageNbrCommentHeaderCommentBodyTest 2 - Second TestCommentBody

User 1 entered comments test 1 - first test which is stored between commentbody and commentbody
User 2 eneterd Test 2 - Second Test which is stored between commentbody
How to query using sql to get these comments as seperate lines
Line 1 - Test 1 - FirstTest
Line 2 - Test 2 - Second Test


Table contains multiple assets and each asset will have comments stored in tags
0
Comment
Question by:raana jella
[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 2000 total points
ID: 40311278
SELECT REPLACE(
           REGEXP_SUBSTR(
               comments,
               'CommentBody.+CommentBody',
               1,
               x.COLUMN_VALUE
           ),
           'CommentBody'
       )
  FROM yourtable,
       TABLE(
           (SELECT COLLECT(LEVEL)
              FROM DUAL
            CONNECT BY LEVEL <= REGEXP_COUNT(yourtable.comments, 'CommentBody.+CommentBody'))
       ) x
 WHERE asset = 'asset01'
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 2000 total points
ID: 40311282
and another version that doesn't require regular expressions, but same basic idea


SELECT asset, SUBSTR(comments, s, e - s)
  FROM (SELECT asset,
               comments,
                 INSTR(
                     comments,
                     'CommentBody',
                     1,
                     COLUMN_VALUE * 2 - 1
                 )
               + LENGTH('CommentBody')
                   s,
               INSTR(
                   comments,
                   'CommentBody',
                   1,
                   COLUMN_VALUE * 2
               )
                   e
          FROM yourtable,
               TABLE(
                   (SELECT COLLECT(LEVEL)
                      FROM DUAL
                    CONNECT BY INSTR(
                                   comments,
                                   'CommentBody',
                                   1,
                                   LEVEL * 2
                               ) != 0)
               ) x
         WHERE asset = 'asset01');
0
 

Author Comment

by:raana jella
ID: 40312030
Thank you,
I will try these solutions and will let you know
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

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…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to take different types of Oracle backups using RMAN.

719 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