2 Replies Latest reply on Apr 24, 2018 7:05 PM by Pierre Yotti

    Client specify return fields

    User553749-Oracle

      Is there any way for the calling client to specify the fields returned in the response to a GET call? I have a request from a calling application that would like to specify a subset of the available fields in the response. My handler is using a source type collection feed.

       

      Thanks,

        • 1. Re: Client specify return fields
          Pierre Yotti

          Hi User553749-Oracle,

           

          Yes. You should use as source typ PL/SQL and build your logik there. The Consumer can give the name of Parameter that he need. and just that value will be return.

           

           

          By the way that Forum is not for you

          Are you an Oracle Employee?

          • 2. Re: Client specify return fields
            Pierre Yotti

            You can use that sample to make your works done

             

            BEGIN

                apex_json.open_object; --  object{

                apex_json.open_array('items'); -- items: [

                FOR cur_rec IN (

                    SELECT

                        empno,

                        ename,

                        job,

                        hiredate,

                        mgr,

                        sal,

                        comm,

                        deptno

                    FROM

                        emp e

                ) LOOP

                    IF

                        all_params = 1

                    THEN

                        apex_json.open_object; -- {

                        apex_json.write('empno',cur_rec.empno);

                        apex_json.write('ename',cur_rec.ename);

                        apex_json.write('job',cur_rec.job);

                        apex_json.write('hiredate',cur_rec.hiredate);

                        apex_json.write('mgr',cur_rec.mgr);

                        apex_json.write('sal',cur_rec.sal);

                        apex_json.write('comm',cur_rec.comm);

                        apex_json.write('deptno',cur_rec.deptno);

                        apex_json.close_object; -- } employee

                    ELSE

                        apex_json.open_object; -- {

                        IF

                            :empno = 1

                        THEN

                            apex_json.write('empno',cur_rec.empno);

                        END IF;

             

             

                        IF

                            :ename = 1

                        THEN

                            apex_json.write('ename',cur_rec.ename);

                        END IF;

             

             

                        IF

                            :job = 1

                        THEN

                            apex_json.write('job',cur_rec.job);

                        END IF;

             

             

                        IF

                            :hiredate = 1

                        THEN

                            apex_json.write('hiredate',cur_rec.hiredate);

                        END IF;

             

             

                        IF

                            :mgr = 1

                        THEN

                            apex_json.write('mgr',cur_rec.mgr);

                        END IF;

             

             

                        IF

                            :sal = 1

                        THEN

                            apex_json.write('sal',cur_rec.sal);

                        END IF;

             

             

                        IF

                            :comm = 1

                        THEN

                            apex_json.write('comm',cur_rec.comm);

                        END IF;

             

             

                        IF

                            :deptno = 1

                        THEN

                            apex_json.write('deptno',cur_rec.deptno);

                        END IF;

             

             

                        apex_json.close_object; -- } employee

                    END IF;

                END LOOP;

             

             

                apex_json.close_array; -- ] employees

                apex_json.close_object; -- } department

            END;

             

            Bildschirmfoto 2018-04-24 um 21.02.42.png

             

             

            Bildschirmfoto 2018-04-24 um 21.03.37.png

             

             

             

            Bildschirmfoto 2018-04-24 um 21.04.22.png

             

             

             

            You can test on postman

            https://apex.oracle.com/pls/apex/pierrealli/hr/employees/