An item in OAF is a java bean which allows a user to interact with the Oracle Apps Framework page e.g. a text box or a choice box etc.
Components or items are always placed inside some region so that they are always displayed as per the Oracle Application Framework standards. Every item or component has specific properties which can be given some values while creation of the OA Framework page e.g. rendered property which allows the bean to be displayed onto the screen it can be true(visible) or false(hidden). Items get rendered on the Oracle Apps Framework page in the fashion as described by the region in which that item has been placed either at declarative/design time or at run-time.
Even these properties can be changed at run-time, but that needs an understanding on how to import the beans and then how to create handle of the bean and then how to set properties. However this is not so much difficult to achieve but still some programming knowledge is needed to achieve this. This is called as run-time control of the bean and is explained in detail for every item in the corresponding item type.
Attachment Image Bean in OAF
An item in OAF is a java bean which allows a user to interact with the Oracle Apps Framework page e.g. a text box or a choice box etc.
Components or items are always placed inside some region so that they are always displayed as per the Oracle Application Framework standards. Every item or component has specific properties which can be given some values while creation of the OA Framework page e.g. rendered property which allows the bean to be displayed onto the screen it can be true(visible) or false(hidden). Items get rendered on the Oracle Apps Framework page in the fashion as described by the region in which that item has been placed either at declarative/design time or at run-time.
Even these properties can be changed at run-time, but that needs an understanding on how to import the beans and then how to create handle of the bean and then how to set properties. However this is not so much difficult to achieve but still some programming knowledge is needed to achieve this. This is called as run-time control of the bean and is explained in detail for every item in the corresponding item type.
FOREIGN KEY in Oracle SQL – PLSQL
In Oracle SQL / PLSQL a FOREIGN KEY is column / field that appears in one table and must appear in another table.
Important points about FOREIGN KEY in Oracle SQL / PLSQL:
- A FOREIGN KEY creates a parent child pattern between two tables.
- The referenced table is called the PARENT table and the table having the FOREIGN KEY is called as the CHILD table.
- The FOREIGN KEY in child table generally references PRIMARY KEY in parent table.
- A foreign key can be defined in CREATE TABLE or ALTER TABLE statement.
Syntax to create a FOREIGN KEY in CREATE statement is:
CREATE TABLE table_name
(column_name1 datatype NULL/NOT NULL
,column_name2 datatype NULL/NOT NULL
, column_name3 datatype NULL/NOT NULL
.
.
column_nameN datatype NULL/NOT NULL
,CONSTRAINT constraint_name
FOREIGN KEY (column_name1, column_name2, . . . column_nameN )
REFERENCES parent_table_name(column_name1, column_name2, . . . column_nameN)
);
Syntax to create a FOREIGN KEY in ALTER statement is:
ALTER TABLE TABLE_NAME
ADD CONSTRAINT constraint_name
FOREIGN KEY (column_name1,column_name2, . . column_nameN)
REFERENCES parent_table_name (column_name1,column_name2, . . column_nameN);
Let’s take an example for understanding:
Scenario 1:
Step 1:
Suppose we want to create a table named ‘employee’ in the database as shown below, with ‘employee_id’ as the primary key for the ‘employee’ table
Employee_Id | Employee_Name | Salary | Department |
101 | Emp A | 10000 | Sales |
102 | Emp B | 20000 | IT |
103 | Emp C | 28000 | IT |
104 | Emp D | 30000 | Support |
105 | Emp E | 32000 | Sales |
And we want to create a table named ‘comm’ with ‘emp_id’ as FOREIGN KEY as shown below:
Emp_Id | Commission_Percent |
102 | 20 |
103 | 20 |
104 | |
105 | 10 |
We can achieve the same as:
CREATE TABLE employee (employee_id NUMBER(10) NOT NULL ,employee_name VARCHAR2(500) NOT NULL ,salary NUMBER(20) NOT NULL ,department VARCHAR2(300) NOT NULL ,CONSTRAINT employee_pk PRIMARY KEY (employee_id) );
CREATE TABLE comm (emp_id NUMBER(10) ,commission_percent NUMBER(20) ,CONSTRAINT fk_employee FOREIGN KEY (emp_id) REFERENCES employee(employee_id) );
Here with the help of the above SQL CREATE statement we have created a table named ‘employee’ that has 4 columns namely ‘employee_id’, ‘employee_name’, ‘department’ and ‘salary’ and we are having the ‘employee_id’ column as the primary key for the ‘employee’ table.
Also, we have created a new table named ‘comm’ which has 2 columns namely ‘emp_id’ and ‘commission_percent’ and we are having ‘emp_id’ as foreign key referencing ‘employee_id’ of ‘employee’ table.
Step 2: Inserting the data in the ‘employee’ table.
INSERT INTO employee VALUES (101,'Emp A',10000,'Sales'); INSERT INTO employee VALUES (102,'Emp B',20000,'IT'); INSERT INTO employee VALUES (103,'Emp C',28000,'IT'); INSERT INTO employee VALUES (104,'Emp D',30000,'Support'); INSERT INTO employee VALUES (105,'Emp E',32000,'Sales');
Step 3: Inserting the data in the ‘comm’ table.
INSERT INTO comm VALUES (102,20); INSERT INTO comm VALUES (103,20); INSERT INTO comm VALUES (104,NULL); INSERT INTO comm VALUES (105,10);
The above SQL INSERT statements will insert 5 rows in the ‘employee’ table and 4 rows in ‘comm’ table.
Now, if we query the employee table as:
SELECT * FROM employee;
We will get the following result:
Employee_Id | Employee_Name | Salary | Department |
101 | Emp A | 10000 | Sales |
102 | Emp B | 20000 | IT |
103 | Emp C | 28000 | IT |
104 | Emp D | 30000 | Support |
105 | Emp E | 32000 | Sales |
Now, if we query the ‘comm’ table as:
SELECT * FROM comm;
We will get the following result:
Emp_Id | Commission_Percent |
102 | 20 |
103 | 20 |
104 | |
105 | 10 |
Here we have successfully created ‘employee’ and ‘comm’ tables with ‘employee_id’ as PRIMARY KEY for ‘employee’ table and ‘emp_id’ as foreign key for ‘comm’ and also inserted data in ‘employee’ and ‘comm’ tables.
If we try to insert one more record in ‘comm’ table of ‘emp_id = 106’ as:
INSERT INTO comm VALUES (106,30);
We get an error that integrity constraint is getting violated and the data cannot be entered, this is because ‘emp_id = 106’ is not found in ‘employee’ table and hence the record cannot be entered in ‘comm’ table.
Scenario 2:
Using ALTER TABLE statement to create a FOREIGN KEY
Syntax for creating a FOREIGN KEY using ALTER TABLE statement is:
ALTER TABLE TABLE_NAME
ADD CONSTRAINT constraint_name
FOREIGN KEY (column_name1,column_name2, . . column_nameN)
REFERENCES parent_table_name (column_name1,column_name2, . . column_nameN);
Example:
ALTER TABLE comm ADD CONSTRAINT comm_fk FOREIGN KEY (emp_id) REFERENCES employee (employee_id);
Hide Show Bean Region in OAF
Region is a part of an Oracle Apps Framework page which acts as a container for the items or components. By default the top most level of an OA Framework page has to be of the “pageLayout” region type.
In OA Framework or OAF the regions can be nested so as to provide the desired layout to the OAF page. Each region is a java bean which acts as a container for the sub-regions or items in any Oracle Application Framework page.
Regions which are parallel in the bean hierarchy, in an OAF page, are called as Siblings and the regions inside a region in an OAF page are called Child regions. The same nomenclature is also applied for Items in OAF. Hence, by default all the regions that you create become the child regions of the pageLayout region as mentioned earlier that the pageLayout region is the top most region in any OA Framework page.
Also every region in OAF has specific properties which can be given some values while creation of the OA Framework page e.g. rendered property which allows the region to be displayed onto the OAF page, as per Oracle Application Framework guidelines (called as OAF standards) this rendered property can have 2 values namely true(visible) or false(hidden). If the region in an OAF page is set to be hidden then all the children regions/items will by default be rendered false once that OAF page is rendered on to screen. Even these properties can be changed at run-time using a Java controller, but that needs an understanding on how to import the region beans and then how to create handle of the bean and then how to set properties. However this is not so much difficult to do but still some Java concept and Java programming knowledge is needed to achieve this. This is called as run-time control of the bean in OAF and is explained in detail for every region in the corresponding region type.
Every region has a specific way of representing the data onto the screen once the OA Framework page is rendered. Hence while creation of a OAF page we have to very cautious in choosing the type of regions. E.g. a defaultDoubleColumn type of region will create two columns and will automatically render all the components created inside it in these two columns once the OAF page is rendered to screen. There are various types of regions available in OA Framework.