I have created an Oracle Form which shows a country list and a text box to display the current date and time for the selected country. Below is an image.
Objects Created For This in Oracle Form
- Data Block
- List Item
- Text Box
- Record Group
- When-New-Form-Instance Trigger
- When-List-Changed Trigger
- Database Function
Record Group Query
Record Group created to get the country list from V$TIMEZONE_NAMES view. The query is as follows:
SELECT DISTINCT tzname, tzname tzname1 FROM V$TIMEZONE_NAMES ORDER BY tzname;
When-New-Form-Instance Trigger Code
Trigger When-New-Form-Instance created to populate the list as shown below:
Declare n number; Begin clear_list('demo.tzonelist'); n := populate_group('tzone'); populate_list('demo.tzonelist', 'tzone'); End;
When-List-Changed Trigger Code
Trigger When-List-Changed created to display current date and time in the text item. Trigger code is as follows:
Begin SELECT get_current_local_time (:demo.tzonelist) into :demo.ctime FROM DUAL; :tlabel := 'Current Date and Time at: '|| :demo.tzonelist; End;
Created a database function get_current_local_time to get the current time for a country passed as a parameter.
You can download the database function script and the Oracle form from the following link:
You will find a SQL script in the zip file function_get_time.sql. First, install this script into your database schema to create the function. Then open the form worldclock.fmb in Oracle form builder and run it.