Home » SQL & PL/SQL » SQL & PL/SQL » json filter unusual behaviour (Oracle Database 12c Enterprise Edition Release 12.2.0.1.0)
json filter unusual behaviour [message #676300] Wed, 29 May 2019 04:54 Go to previous message
sss111ind
Messages: 634
Registered: April 2012
Location: India
Senior Member

Dear All,

I faced unusual behaviour while putting filter in where clause. It is working fine when direct value(MILLER) is provided but throws the below error in SQL Developer and database getting disconnected when the value stored in the variable i.e l_ename used. Please help.

Error report -
No more data to read from socket

ALTER TABLE EMP ADD JSON_DATA VARCHAR2(100);
update EMP SET JSON_DATA ='{"data": {"ename": "MILLER"}}'WHERE ENAME ='MILLER' ;
update EMP SET JSON_DATA ='{"data": {"ename": "KING"}}'WHERE ENAME ='KING' ;
commit;

DECLARE
    l_ename    VARCHAR2(20) := 'MILLER';
    l_exists   NUMBER;
BEGIN
    SELECT
        1
    INTO l_exists
    FROM
        emp,
        JSON_TABLE ( json_data, '$.data'
                COLUMNS (
                    newename VARCHAR2 PATH '$.ename'
                )
            )
        t
    WHERE
        deptno = 10
        AND t.newename = 'MILLER';--l_ename 

END;    

Regards.
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: can we call an sql script from the code of a stored procedure
Next Topic: varchar2 byte or char semantics
Goto Forum:
  


Current Time: Thu Apr 18 20:56:32 CDT 2024