Tuesday, April 26, 2022

VBCS - Sample WEB application | Employee CRUD operation web application

Use case:

  1. Create a web application
  2. Create an Employee business object
  3. Page to list all the employees.
  4. Page to on board new employee
  5. Page to view all employee details
  6. Page to update an employee
  7. Page to delete an employee

Steps in detail with screenshots:

Home >> Visual Builder


New Application


Provide application name >> Finish



Navigation hamburger >> Business Objects


Business Object


Provide Business Object Name


By default,  we have 5 fields:
Id, CreatedBy, CreationDate, LastUpdatedBy,LastUpdatedDate


Created new field: FirstName, LastName, Age, EmailAddress


Create web application





See the structure of the web apps.


Take Table component


Go to Quick Start


Add Data to Business object


Select Employee BO.


Add fields to show in the employee list.



Add create Page


Select same BO.


Select fields to create for onboard new employee.


Add edit page


Select Employee BO.


Add fields that need to be updated.


Add Detail Page.


Select Employee BO.


Select fields to show details



Add delete action


Select Employee BO.


Finish


The final page looks like below:


All the pages created under main folder.



Lets go to Preview and test .


Click On board


Add an employee


Employee created.


Same way added another employee.

The page looks little messed up so modified the page formats.



Select one employee row and click update employee.

Update the employee fields.


You can see the employee fields have been modified.


Clcik on Employee detail.


See the employee details.


Select employee and delete employee.


The employee gets deleted successfully.


Go to the Business Object >> Data and see all the current employee data.



VBCS page links

All VBCS POCs links below:

  1. VBCS overview
  2. VBCS - typical visual application workflow
  3. VBCS - Understand variables
  4. VBCS - Understand actions and action chains
  5. VBCS - access and secure business objects
  6. VBCS - important parts or tools under Navigator
  7. VBCS - constituents of a web application
  8. VBCS - provisioning visual builder instance
  9. VBCS - task1 - Create a web application
  10. VBCS - task2 - Create business objects and import data.
  11. VBCS - task3 - create a business objects diagram
  12. VBCS - task4 - How to check and test Business Object rest endpoints
  13. VBCS - task5 - Use main-start page to display one business object like departments
  14. VBCS - task6 - add a page to create object instance like departments using add create page quick start
  15. VBCS - task7 - add a page to display business object like employees
  16. VBCS - task8 - add a page to create employee business object
  17. VBCS - task9 - change the name of the main-start page
  18. VBCS - task10 - Add navigation between pages in a webapp | Action chain
  19. VBCS - task11 - add a page to edit business object like department's details
  20. VBCS - task12 - add a button to delete a department
  21. VBCS - task13 - change the app's deafult page
  22. VBCS - task14 - Access data from an external REST service
  23. VBCS - task15 - access data from an external REST service using service connection - Define by endpoint option
  24. VBCS - task16 - Enable the web app as a PWA
  25. VBCS - task17 - stage the application and import data into the application
  26. VBCS - task18 - publish the application
  27. VBCS - Load data before the page load in oracle visual builder | vbEnter event in VBCS
  28. VBCS - sample web application | Employee CRUD operation web application
  29. VBCS SDP vs ADP
  30. VBCS - Parent Child Relationship between Business objects
  31. VBCS - Dependent or Cascading Select dropdown
  32. VBCS - Export data to Excel component
  33. VBCS - Call OIC integration from Visual Builder
  34. VBCS - Create Custom Javascript function in Visual Builder

References:


OIC - Database package call to insert Varray size of data | DB package insert in oracle integration

Use Case: Here, we will create a package which is accepting Varray type of elements and then call it and feed customers data from Oracle Integration.

Note: use Varray or nested table to create a valid collection type of the fields. Here we will use Varray types.

Create VARRAY type:

Create or replace TYPE NUMBER_ARRAY IS VARRAY(1000) OF INTEGER;

Create or replace TYPE STRING_ARRAY IS VARRAY(1000) OF VARCHAR2(200);

Create or replace TYPE STRING_ARRAY_ID IS VARRAY(1000) OF VARCHAR2(20);

Package specification:

Create or replace package PKG_CUSTOMERS_MULT AS

PROCEDURE addCustomers(P_Id STRING_ARRAY_ID, P_Name STRING_ARRAY, P_Age NUMBER_ARRAY, P_Address STRING_ARRAY);

END PKG_CUSTOMERS_MULT;

/

PACKAGE BODY:

Create or replace package PKG_CUSTOMERS_MULT AS

PROCEDURE addCustomers(P_Id STRING_ARRAY_ID, P_Name STRING_ARRAY, P_Age NUMBER_ARRAY, P_Address STRING_ARRAY)

IS

BEGIN

FOR i IN P_Id.FIRST .. P_Id.LAST

LOOP

INSERT INTO CUSTOMER1(ID,NAME,AGE,ADDRESS) VALUES(P_Id(i),P_Name(i),P_Age(i),P_Address(i));

END LOOP;

END addCustomers;

END PKG_CUSTOMERS_MULT;

/


Steps in Detail:

Integration flow:


Rest trigger adapter configurarion







Invoke stored procedure steps:




Map rest request to db target package elements.



Note: In the map, for each package Varray field, for each cuatomers, we have to map the item elements individually.

For example, - for P_ID

<P_ID>

   For each customer,

      <P_ID_ITEM>

         Id of each customer

      </P_ID_ITEM>

</P_ID>

Testing:

Input:


Output: DB table:



Monday, April 25, 2022

OIC - Call DB package insert operation | one to one database insert using Package

Use Case: we will create a simple package and using OIC integration, insert the customer records one by one to the database.

Highlevel steps:

  1. Create a customer table and package to insert customer records
  2. Rest trigger to accept customer records.
  3. Call package using db adapter
  4. For each customer record, insert to database.

Create table:

Create table customer1(

Id varchar2(20),

Name varchar2(200),

Age number,

Address varchar2(200));


Package Specification:

CREATE OR REPLACE PACKAGE PCK_CUSTOMER AS

PROCEDURE addCustomer(c_id customer1.id%type,

c_name customer1.Name%type,

c_age customer1.age%type,

c_addr customer1.address%type);

END PCK_CUSTOMER;

/

Package Body:

CREATE OR REPLACE PACKAGE BODY PCK_CUSTOMER AS

PROCEDURE addCustomer(c_id customer1.id%type,

c_name customer1.Name%type,

c_age customer1.age%type,

c_addr customer1.address%type)

IS

BEGIN

INSERT INTO CUSTOMER1(ID NAME,AGE,ADDRESS) VALUES(c_id, c_name, c_age, c_addr);

END addCustomer;

END PCK_Customer;

/

Rest trigger request json:

{

"Customers":{

"Customer":[

{

"Id":1,

"Name":"aaa",

"Age":12,

"Address":"qqq"

},

{

"Id":2,

"Name":"aaa",

"Age":12,

"Address":"qqq"

}]

}}



Steps in detail:

Integration flow:


Rest trigger configuration:







For each customer


Invoke  a stored procedure.




Map customer to db target fields.



Thursday, April 21, 2022

DB Offset - Fetch clause

Offset and Fetch clauses are used in conjunction with Select and order by clause to provide a means to retrieve a range of records.

Offset: the offset argument is used to identify the starting point to retirn rows from a result set.

Fetch: It is used to return a set of number of rows.

Syntax:

Select column_name(s)

From table_name

Order by column_name

Offset rows_to_skip ROWS

Fetch Next number_of_rows ROWS ONLY;


Example:

Suppose you have 9 rows in a db table and you want to fetch 3rd to 7th one

Select orderNumber,Customer

From orders

Order by orderNumber

Offset 2 ROWS

Fetch Next 5 Rows ONLY;


OIC - DB Procedure call | DB adapter 10 MB limit overcoming solution

Use Case: If we run a db select query and it has humungous data (more than 10MB) then it will fail as it has reached the limit. We can avoid such error using  SQL with offset. In this use case, we will use a Stored procedure.

To know about Offset & Fetch:

https://soalicious.blogspot.com/2022/04/db-offset-fetch-clause.html

Highlevel steps:

  1. Create a db table orders.
  2. Create a offset select db query
  3. Wrap the sql query in a stored procedure.
  4. In the integration, 
    1. 1st we take the total row count using db adaptet call
    2. Determine number of iteration - ceiling(totalRows / batch size)
    3. For each iteration,
      1. We will select the rows by offset
      2. For each row, we will log the row details
      3. Increment the counter and offset.
Steps in detail:

Create a table orders:

Create table orders(
"orderNumber" VARCHAR2(20 BYTE),
"Customer" VARCHAR2(200 BYTE)
)

Select offset db query:

Select "orderNumber","Customer" from orders order by "orderNumber"
Offset 2 rows 
Fetch Next 3 rows only

Sql query wrapped up in stored procedure:

CREATE OR REPLACE PROCEDURE OrdersByOffset(in_fetchSize NUMBER, in_offset NUMBER, p_Orders out SYS_REFCURSOR)
IS
BEGIN
OPEN p_Orders for
SELECT "orderNumber","Customer" 
FROM orders
ORDER BY "orderNumber"
OFFSET in_offset ROWS
FETCH NEXT in_fetchSize ROWS ONLY;
END;
/

Create a scheduled orchestration and count total rows from the dp adapter using the following sql:

Select count(1) from orders


Total rows fetch db adaptet config:




Create variables for :

totalRows: number of rows fetched from db adapter.

batchSize: number(4.0)

totalIteration: ceiling(orajs29:divide($totalRows,$batchSize))




Next step is to invoke stored procedure by offset to get the batch of rows.


Assign Counter and Offset:

Counter: number(1)

fetchSize: $batchSize

offSet: number(0)



In the while,

$Counter <=$totalIteration



Invoke stored procedure.





Map the fetchSize and Offset.




Now for each fetched row, will log them and increment the counter and offset.


For each row,



Log the row details:

concat("Order Details - OrderNr / Customer :",$currentRow/nsmpr3:Row/nsmpr3:Column[1]," / ",$currentRow/nsmpr3:Row/nsmpr3:Column[2])


Counter: $Counter + 1

offSet : $offSet + $fetchSize



Testing:

In my case, i have totalRows = 9 in the db orders table and batchSize= 4, so total iterations=9 / 4 = 3.








Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...