Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert RECORD type parameter to XML or json in oracle?

user8326781Jun 18 2021 — edited Jun 18 2021

R_Al.op_record is a user defined RECORD type in oracle. I can not compile the following code. What I want is to convert the user defined RECORD type in to an xml or json without referring to its attributes one by one. Is this possible to do? Can we do this using dynamic sql?
The compilation error i get is .....Error: PLS-00306: wrong number or types of arguments in call to 'XMLTYPE'

TYPE op_record IS RECORD (
        operation_row_count           BINARY_INTEGER,
        operation_id_tab              number_type,
        operation_no_tab              number_type,
        operation_description_tab     char_50_type);
PROCEDURE Update_S(
       op_rec_ IN R_Al.op_record)
    IS
        v_xml   SYS.XMLTYPE;
        mytype R_Al.op_record;
    BEGIN
        mytype := op_rec_;
        v_xml := xmltype(mytype);
    END Update_S;

Comments

Post Details

Added on Jun 18 2021
7 comments
2,407 views