Solved

how to solve this query?

Posted on 2014-07-24
5
203 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 76

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 76

Expert Comment

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

Let me work on it.
0
 
LVL 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot open form error 6 66
Error executing command from server 6 42
Oracle - Create Procedure with Paramater 16 57
sort a spool into file output in oracle 1 22
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
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.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now