Solved

how to solve this query?

Posted on 2014-07-24
5
211 Views
Last Modified: 2014-07-27
Hi expert,
below is my query
SELECT *
  FROM (SELECT REGEXP_REPLACE(
                   REGEXP_SUBSTR(
                       :JSONdata,
                       '"[0-9]+".+?}}',
                       1,
                       LEVEL
                   ),
                   '^[{"]+|[},]+&'
               )
                   AS rec
          FROM DUAL
        CONNECT BY LEVEL <= 11)
 WHERE rec IS NOT NULL;

Open in new window


jsondata is given here :
 {"1":{"YBG":1,"BNT":"vc{//}}vm"},"2":{"YBG":1,"BNT":"vc}{}}vm"},"3":{"YBG":1,"BNT":"vc{}}vm"}}

Open in new window


Note:Note:inside 'vcvm'  IF i give any special character . it will take a whole string it should not trim any characters
result:
1":{"YBG":1,"BNT":"vc{//}vm"},"2":{"YBG":1,"BNT":"vc}{
3":{"YBG":1,"BNT":"vc{

expected result:
 1":{"YBG":1,"BNT":"vc}{//}vm
 2":{"YBG":1,"BNT":"vc}{}}vm
 3":{"YBG":1,"BNT":"vc}{}}vm

Regards
Thomos
0
Comment
Question by:deve_thomos
  • 3
  • 2
5 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40217348
I get the expected results.

Below is my test case (use sqlplus against an 11.2.0.2 database) and my results.

My guess is whatever you are using to execute the SQL is interpreting the double slashes in some way.



SQL> var JSONdata varchar2(100)
SQL>
SQL> exec :JSONdata := '{"1":{"YBG":1,"BNT":"vc{//}}vm"},"2":{"YBG":1,"BNT":"vc}{}}vm"},"3":{"YBG":1,"BNT":"vc{}}vm"}}'

PL/SQL procedure successfully completed.

SQL> SELECT *
  2    FROM (SELECT REGEXP_REPLACE(
  3                     REGEXP_SUBSTR(
  4                         :JSONdata,
  5                         '"[0-9]+".+?}}',
  6                         1,
  7                         LEVEL
  8                     ),
  9                     '^[{"]+|[},]+&'
 10                 )
 11                     AS rec
 12            FROM DUAL
 13          CONNECT BY LEVEL <= 11)
 14   WHERE rec IS NOT NULL;

1":{"YBG":1,"BNT":"vc{//}}
2":{"YBG":1,"BNT":"vc}{}}
3":{"YBG":1,"BNT":"vc{}}

Open in new window

0
 

Author Comment

by:deve_thomos
ID: 40217360
hello slight wv

see my  expeceted output:
1":{"YBG":1,"BNT":"vc}{//}vm
 2":{"YBG":1,"BNT":"vc}{}}vm
 3":{"YBG":1,"BNT":"vc}{}}vm

your output:
1":{"YBG":1,"BNT":"vc{//}}
2":{"YBG":1,"BNT":"vc}{}}
3":{"YBG":1,"BNT":"vc{}}

After  that  all charecters 'vm' characters are missing.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40217370
Missed that.

Let me work on it.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40217387
You had a typo from the solution in your previous question.

Based on the new requirement try this:
var JSONdata varchar2(100)

exec :JSONdata := '{"1":{"YBG":1,"BNT":"vc{//}}vm"},"2":{"YBG":1,"BNT":"vc}{}}vm"},"3":{"YBG":1,"BNT":"vc{}}vm"}}'


SELECT *
  FROM (SELECT
  	REGEXP_REPLACE(
                   REGEXP_SUBSTR(
                       :JSONdata,
                       '"[0-9]+".+?"}',
                       1,
                       LEVEL
                   )
                   ,
                   '^[{"]+|["}]+$'
               )
                   AS rec
          FROM DUAL
        CONNECT BY LEVEL <= 11)
 WHERE rec IS NOT NULL;

Open in new window

0
 

Author Closing Comment

by:deve_thomos
ID: 40223468
Thanks a lot...
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

733 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