Solved

how to solve this query?

Posted on 2014-07-24
5
200 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
Comment Utility
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
Comment Utility
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)
Comment Utility
Missed that.

Let me work on it.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
oracle 10G 5 48
Cannot open form error 6 47
sql query 5 52
Dataware house query tuning 9 29
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 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

16 Experts available now in Live!

Get 1:1 Help Now