APEX_ITEM
is a PL/SQL package that you can use to programmatically put items on the screen. The package also contains a function to put hidden items on the screen. Hidden items are items that are placed in a webpage but are not visible. However, they can contain a value. In this way, you can make each row in a report unique. We will make an updatable report which makes use of the APEX_ITEM
API.
First, we will make a classic report based on the APP_EVENTS
table.
select apex_item.hidden(1,id)||apex_item.text(2,event) appevent , apex_item.date_popup(3,rownum,event_date,'dd-mm-yyyy') event_date , apex_item.text(4,location) location , apex_item.text(5,event_type) event_type from app_events;
[1346_07_01.txt]
Now we will make a button and a page process to enable the saving of data.
begin for i in 1..apex_application.g_f01.count loop update app_events set event = apex_application.g_f02(i) , event_date = to_date(apex_application.g_f03(i), 'dd-mm-yyyy') , location = apex_application.g_f04(i) , event_type = apex_application.g_f05(i) where id = to_number(apex_application.g_f01(i)); end loop; end;
[1346_07_2.txt]
With APEX_ITEM
you can put an item on the screen. The first parameter in the function (hidden, text, or date_popup)
is the index which you can use to find the item back. Let's say you use the following command to put an item on the screen:
APEX_ITEM.TEXT(2,'COLUMN_NAME')
When submitted, the values of the APEX items will be stored in the PL/SQL array APEX_APPLICATION.G_F0X
. Then you can find this item back with:
APEX_APPLICATION.G_F02(i)
.
Where i
is the row indicator in case you are working with a multi row tabular form.
Furthermore, you can use the first variable to do some aggregate functions like count. Use it in the following way:
APEX_APPLICATION.G_F01.COUNT
.
Note that the example in this recipe only handles existing rows.
18.118.28.179