Forum Stats

  • 3,728,036 Users
  • 2,245,522 Discussions
  • 7,853,257 Comments

Discussions

sending response

Arif2018
Arif2018 Member Posts: 203 Red Ribbon

i am using ORDS to expose webservices to salesforce, basically using my webservice salesforce will post or insert the data into oracle staging table, now there is a new requirement of sending response back to salesforce that records are inserted sucessfully , incase of any errors while inserting the same to be communicated to Salesforce users.How can it be acheived.

Tagged:

Answers

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 7,656 Employee

    In your webservice take proper care of HTTP Response Status codes (201 vs 400), and then setting appropriate messages on the response body.

    If you share how you've defined your webservice, then we can give better advice.

    Arif2018
  • Arif2018
    Arif2018 Member Posts: 203 Red Ribbon

    Hi Jeff,


    i have written a procedure for sending the bulk data in array as follows, not sure how send the respnonse back to caller.

    [code]

    CREATE TABLE DEPT1

    (

     DEPTNO NUMBER(2),

     DNAME  VARCHAR2(14 CHAR),

     LOC   VARCHAR2(13 CHAR)

    )

    --procedure for inserting the data

    CREATE OR REPLACE PROCEDURE CLGINFO.create_dept (p_data IN BLOB)

    AS

    BEGIN

     INSERT INTO dept1 (deptno, dname)

      SELECT *

      FROM  json_table(p_data FORMAT JSON, '$.dept[*].department'

          COLUMNS (

           deptno NUMBER  PATH '$.department_no',

           dname  VARCHAR2 PATH '$.department_name'));

     COMMIT;

    EXCEPTION

     WHEN OTHERS THEN

      HTP.print(SQLERRM);

    END;

    /




    --payload

    {

       "departments":[

          {

             "department":{

                "department_name":"RIFAS",

                "department_no":03,

                 "loc":03

             }

          },

          {

             "department":{

                "department_name":"SDFG",

                "department_no":04,

               "loc":04

             }

          }

       ]

    }


    [/code]

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 7,656 Employee

    EXCEPTION

     WHEN OTHERS THEN

      HTP.print(SQLERRM);



    So IF something bad happens, you're giving them something. But otherwise you are not.

    At best you would want to return a link to the data you just loaded, or a summary of what was loaded.

  • Arif2018
    Arif2018 Member Posts: 203 Red Ribbon

    Any examples, do you mean a link of data loaded summary.

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 7,656 Employee

    lots of examples on my blog

  • Arif2018
    Arif2018 Member Posts: 203 Red Ribbon

    can u post the link to your blogs.

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 7,656 Employee

    thatjeffsmith.com

Sign In or Register to comment.