Now we will start implement integration layer before I will create REST api in the ORDS. I will first create a integration as a package and then add a function which will call logic.get_rows_by_deptno and fetch the data from logic layer to the integration layer. You can also think to have integration as a separate database schema so that you can make separation between logic and rest functionality. In my case I will create integration package. see the code below.
create or replace type
t_dept_obj as object
(
empno number
,
ename varchar2(100)
,
hiredate date
,
dname varchar2(100)
,
job varchar2(100)
,
salary number
,
location varchar2(100)
);
create or replace type
t_dept_tblo is table of
t_dept_obj;
create or replace package
integration as
function
get_rows_by_deptno_piped(p_in_deptno in
dept.deptno%type
) return
t_dept_tblo pipelined
;
end
integration;
--In the package body I will add a function integration.get_rows_by_deptno_piped and call logic.get_rows_by_deptno. I will also add few local variables like lv_api_id = 3 and lv_api_type = GET and lv_payload
--because when the webservice endpoints will be called I will log it into the rest request log table. I want to see that which department number was sent in the request. See the below code for
--integration.get_rows_by_deptno_piped