Create Auto-Increment
Client-Side
Client-Side
In the
name of Allah, Most Gracious, Most Merciful
Praise
be to Allah, blessing and peace be upon our prophet Mohammed, his family and
his companions. After that,
Auto-incremented allows a unique number to be incremented automatically when a
new record is inserted into a table.
Auto increment has two types
- Server Side.
- Client Side.
Task Definition:
Create an Auto-increment Number at Client Side.
Task Solution:
Let's start doing that task.
Once, you login into Oracle Apex, open SQL WORKSHOP.
Create A New Database Table
CREATE TABLE SERIAL_DEMO (
DEMO_ID NUMBER(11) PRIMARY KEY,
DEMO_DESC VARCHAR2(55)
) ;
/
- Create a new Oracle Apex Page as follow...
- Select a new blank Oracle Apex Page. Then, click next to continue ...
- Specify the Oracle Apex Page name as follow. Then, click next to continue ...
- Select create a new navigation menu entry and specify its display name in the new navigation menu entry as follow. Then, click next to continue ...
- Check the page summary. Then, press Finish to confirm its creation.
- The blank page is successfully created as follow.
- Press run button to check its successful creation.
- Select Regions, press right click with mouse. Then, select Create Region.
- Now a new empty region is created. Rename it with Serial_Demo.
- Select the new created region, press right click with mouse and select Create Page Item.
- Follow the necessary modification concerning; name, label.
- Under Source> select Type > Database Column .& specify the Database Column name as Demo_Id.
- Create another page item called Demo_desc the like in the previous steps.
- Follow the necessary modification concerning; name, label.
- Under Source> select Type > Database Column .& specify the Database Column name as Demo_desc.
- Press Save & Run button to check the last modification.
- Select the process tab, then the process folder, press right click with mouse and select Create Process.
- Follow the necessary process modification concerning; name, label.
- Settings > select Table Name > Serial_Demo
- Primary Key Column > Demo_ID
- Primary Key Item > F3_Demo_ID.
- Create another process called Auto_Number_Process.
- Type PL/SQL Code
PL/SQL Code
BEGIN
SELECT NVL( MAX (DEMO_ID + 1),1)
INTO :P3_DEMO_ID
FROM SERIAL_DEMO ;
END;
/
- Select Regions, press right click with mouse and select Create Button.
- Follow the necessary button creation concerning; name & label.
- Layout > Button Position > Create
- Behavior > Action > Submit Page.
- Select SQL WORKSHOP drop down list
- Select Object Browser.
- Right click on Object Browser.
- Select Open Link in a new tab as follow...
- Object Browser will be opened in a new tab as follow.
- Search for the table name.
- Check for any data in the table data tab. You will find no data exists.
- Go pack to the Page Designer & run the page in the browner.
- Insert data in the demo desc page item.
- Press Create button.
- I accidentally stacked in this error for 2 minutes.
- Then go to inspect for it.
- I found a logical error in the sequence of the two processes i have just created.
- I fixed it by preceding the auto increment pl/sql code before inserting it.
- So i re-order the processes with the logical correct sequence to its execution then it works successfully.
- Run the page then input some data.
- Press Create button.
- A pop-up message declares a successful inputs into the database.
- Now, let's check data into the database.
- I shared this task with you since it involves many web concepts really we all need to recognize. In Shaa Allah, later on i will discuss these concepts with you to realize how Oracle Apex works.
- Oracle recommends working with server Side because it is more reliable and secure than the client side code.
Learn more about:
Hope this helps...
My success only comes from Allah, pls. note your comments and
suggestions are great help for me in progress thanks in advance.
No comments :
Post a Comment