How to create update process for single entry form in APEX 4.1 - forms

I'm new to APEX. I am sure this solution might be available, but was unable to find a proper answer anywhere.
Here is the case scenario: (Provide user a capability to update a particular report row).
Page 1 has report A in which there is a particular column say column B which has links to all its row, by clicking on one particular row user navigates to the new page (Page2).
Page 2 has single entry form in region one which has list of items (around 10) and on region 2 of the same page (page 2) it has a tabular form.
Some of the items in region 1 of page 2 are populated based on the information from page 1 report details. Some items have LOVs and some item user can add information.
The tabular form in region 2 of page 2 is generated based on line item id which can be edited by the user. The tabular form is associated to one table only.
There are two buttons on the page, cancel button takes back to the report page, whereas the save button will save the data to the database tables. The single form items will update 2 tables, whereas tabular form will update one tables.
How the process needs to be establish for updating the underlying tables through apex.
Right now Tabular form has MRU update built in process(but I am not sure can I use this process in coordination with single entry form or it is better to create a separate process which handles both updates)
Can anybody give me an idea how this can be accomplished, or a link where such process has been explained?

You will need to manually create plsql processes to process the submitted values and apply them to your tables. You can not use the built-in row processing to do this: you can not define 2 per page. (That makes sense because you can not indicate which column maps to which table. You can only define "database column" as source for an item. This means that even if you were to have 2 processes, these columns would be attempted to process on both processes, which would lead to errors.)
Take a look at this post for some ideas on how to set the processes up: https://stackoverflow.com/a/7877933/814048

if :P42_ORDER_STATUS in ('IP','OW') then
begin
FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
update sales_mst set ORDER_STATUS = 'DR'
where id = to_number(apex_application.g_f01(i));
end loop;
end;
end if;

Related

ms access unbound datasheet or alternative control

I want to have an unbound datasheet control in ms access forms or any other alternative tabular data showing control, where I can add rows dynamically and save it to database on form submission not on each next row.
I tried bound datasheet but it saves records as new rows is created, is there some property or method which prevent record saving automatically.
or any other alternative.
below is snap (red portion is not created, I want like this).
actually I want to save order
which has child table order_details
for order details I want this control
No, the records have to exist somewhere.
Use a temp table where you create 10 or so empty records before opening the form, and delete all records when you close the form.

Can you control the print order of Access form with subforms?

I have a form in Access 2007 with 2 subforms. Each one has it's own table. All 3 tables have a primary key to link on. The 2 subforms can be linked by the primary key and a second field. Users want to print the form, rather then a report, to review the record data. When the form prints the order is as follows:
Main form, [subform1]![record1], [subform1]![record2], etc, [subform2]![record1], [subform2]![record2], etc, last page of the main form.
How do I force the form print order to be:
Main form, [subform1]![record1], [subform2]![record1], [subform1]![record2], [subform2]![record2], etc, last page of the main form.
I've tried setting up the table relationships and checked all the Master-Child links. The form navigates through records correctly. I've also looked at print options but didn't see a solution there either.
You will need a query where you join the master table with the two subtables.
Then apply the requested order and create new form for printing.
Still, a report would be better. Remember to remove any sorting from the query and specify that in the report.

APEX - Can a Tabular Form with its MRU functionality have filtering functionality like an Interactive Report?

What I really need is a Tabular form that allows me to update multiple rows at a time while being filterable like an Interactive report. Any chance this is even remotely possible?
I would also like to hijack the row checkboxes on a tabular form that appear when the 'delete' functionality is activated and use them to select which rows get assigned a to a group based on a common attribute. (i.e. My table contains parts in my inventory and I need to be able to assign parts with common attributes to a group for processing)
Perhaps a group-by function that creates a new row in a 'Group' table with the group as the PK and the parts assigned to that group as a list or something...?
Thoughts? I am kind of at a loss...
It's really not that hard :) You can easily transform an IR into a pseudo-tabular form. And even though there are always more stylish and elegant solutions, those usually involve lots of javascript and/or plugins. They're nice, but not always what you want or need of course.
So how to manipulate your output? Use the APEX_ITEM api!
Quick example. I have an ir built on emp. I added a checkbox and textbox.
select empno, ename, deptno,
apex_item.checkbox(1, empno) empno_selected,
apex_item.text(2, ename, 10, 10) ename_edit
from emp
Don't forget: in the column attributes, set Display text as to Standard Report Column. If you don't, the output will be in plain text. Since apex_item generates html code, you don't want the plain text of course :)
Now, to be able to perform DML based on the actions you do in those generated fields, you will need a process. Let me start off by pointing out though that the generated items are stored in application variables, namely in arrays in APEX_APPLICATION.
Take note of the behaviour of checkboxes: only ticked boxes will have their value stored in the array!
As an example, i've made this small On Submit process (also adding a SUBMIT button on the form to actually perform the submit...)
for i in 1..apex_application.g_f01.count
loop
insert into empselected(empno, selectiondate, ename_changed)
values(apex_application.g_f01(i), sysdate, apex_application.g_f02(i));
end loop;
This will loop over the records with the checkboxes ticked, and insert them into some table. For example, i ticked the box with KING and edited the textfield. See record nr 2 (1 is from a previous action ;))
It's not all the way there yet though. You still miss out on the functionality of a tabular form and it's processes, and things like optimistic locking. If you want to stay with tabular forms, you can also, for example, check out this link. There have also been some questions here about writing your own mru processes etc, like this one ;)
It is possisble, using the same tabular form.
Create an item (text item) in the tabular form region.
Create a submit button (Create a button displayed among this region's items)
Modify the where clause in the tabular form region source
For Example, you need search by customer name:
WHERE lower(CUSTOMER_NAME) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
If you need to search for other field only add other condition to the where clause
WHERE (
lower(CUSTOMER_NAME) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
or lower(CUSTOMER_address) LIKE '%'||lower(nvl(:PXX_SEARCH,CUSOTOMER_NAME))||'%'
)
Simple and use the same tabular form.

APEX - Creating a page with multiple forms linked to multiple related tables... that all submit with one button?

I have two tables in APEX that are linked by their primary key. One table (APEX_MAIN) holds the basic metadata of a document in our system and the other (APEX_DATES) holds important dates related to that document's processing.
For my team I have created a contrl panel where they can interact with all of this data. The issue is that right now they alter the information in APEX_MAIN on a page then they alter APEX_DATES on another. I would really like to be able to have these forms on the same page and submit updates to their respective tables & rows with a single submit button. I have set this up currently using two different regions on the same page but I am getting errors both with the initial fetching of the rows (Which ever row is fetched 2nd seems to work but then the page items in the form that was fetched 1st are empty?) and with submitting (It give some error about information in the DB having been altered since the update request was sent). Can anyone help me?
It is a limitation of the built-in Apex forms that you can only have one automated row fetch process per page, unfortunately. You can have more than one form region per page, but you have to code all the fetch and submit processing yourself if you do (not that difficult really, but you need to take care of optimistic locking etc. yourself too).
Splitting one table's form over several regions is perfectly possible, even using the built-in form functionality, because the region itself is just a layout object, it has no functionality associated with it.
Building forms manually is quite straight-forward but a bit more work.
Items
These should have the source set to "Static Text" rather than database column.
Buttons
You will need button like Create, Apply Changes, Delete that submit the page. These need unique request values so that you know which table is being processed, e.g. CREATE_EMP. You can make the buttons display conditionally, e.g. Create only when PK item is null.
Row Fetch Process
This will be a simple PL/SQL process like:
select ename, job, sal
into :p1_ename, :p1_job, :p1_sal
from emp
where empno = :p1_empno;
It will need to be conditional so that it only fires on entry to the form and not after every page load - otherwise if there are validation errors any edits will be lost. This can be controlled by a hidden item that is initially null but set to a non-null value on page load. Only fetch the row if the hidden item is null.
Submit Process(es)
You could have 3 separate processes for insert, update, delete associated with the buttons, or a single process that looks at the :request value to see what needs doing. Either way the processes will contain simple DML like:
insert into emp (empno, ename, job, sal)
values (:p1_empno, :p1_ename, :p1_job, :p1_sal);
Optimistic Locking
I omitted this above for simplicity, but one thing the built-in forms do for you is handle "optimistic locking" to prevent 2 users updating the same record simultaneously, with one's update overwriting the other's. There are various methods you can use to do this. A common one is to use OWA_OPT_LOCK.CHECKSUM to compare the record as it was when selected with as it is at the point of committing the update.
In fetch process:
select ename, job, sal, owa_opt_lock.checksum('SCOTT','EMP',ROWID)
into :p1_ename, :p1_job, :p1_sal, :p1_checksum
from emp
where empno = :p1_empno;
In submit process for update:
update emp
set job = :p1_job, sal = :p1_sal
where empno = :p1_empno
and owa_opt_lock.checksum('SCOTT','EMP',ROWID) = :p1_checksum;
if sql%rowcount = 0 then
-- handle fact that update failed e.g. raise_application_error
end if;
Another, easier solution for the fetching part is creating a view with all the feilds that you need.
The weak point is it that you later need to alter the "submit" code to insert to the tables that are the source for the view data

ms access Add, Edit, Delete Items through an Access form

I'm not real familiar with inputting data through forms. Up until now I've just been handling the data from the table. However, now I have a table with two pieces of information:
Group ID
Each ID is in a group, not all IDs are represented in the table (ie there is another table with a complete list of IDs...many to one), and multiple IDs can be associated with the same group.
I want to make a form that allows the user to add a new ID/group row, edit an existing ID's "Group," and delete an existing Row. I want the user to see the changes he/she has made. I think there's a way to show a snapshot of the table as part of the form? How do I do all this?
Have you tried a continuous form? You can use a combo to display additional information for each control/field, if that is required.
EDIT re Comment
From your comments and original post, it seems that what may suit is a main form and subform. The subform can be set to prevent editing - it will display the existing groups. The main form will have your combos and buttons.
As to the various types of form, look at the Views Allowed property for the form, you will find:
Single Form (suitable for main form)
Continuous Form (suitable for subform)
Datasheet
Link one table (or query) to the main form and your second table (or query) to a sub form. Drag your sub form onto the main form. Tie the two forms together in properties (sub form) under link master fields and link child fields add the key ID.