Multi Row Update for Tabular Form
1) I'm trying to understand how the built-in MRU works for tabular forms: While running through every row, does it check for changes before issuing an UPDATE or does it blindly UPDATE every row in the current pagination range?
2) If I need to write my own Multi Row Update process for tabular forms, could someone give me some tips on how to do that?
Thanks,
Pavel
1) It stored a checksum for each row that it renders. It calculates the checksum again before processing the rows. The UPDATE statement it issues has a predicate like where old_checksum!=new_checksumSo, it only updates the rows that have at least 1 column value that is different (causing the row checksum to be different)
2) See the howto at http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html
Similar Messages
-
Multiple Users - Tabular Forms - Multi Row Update.....
Greetings All,
Any comments, assistance, links, or even answers on the following situation would be much appreciated....
I have a Application Express 4.0 (Could upgrade to 4.1 if it would help this issue)
I have a wizard generated tabular form on a table, the form will show up to 600 records (rows) on a page.
Part 1:
The situation:
User 1: Opens the form and brings up latest data set.
User 2: Opens the form and brings up the latest data set.
User 1: Changes data for record 1
User 1: Hits submit. The data is saved.
User 2: Changes data for record 1
User 2: Changes data for record 2
User 2: Hits submit. The following error is produced:
Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "3EE15D666E9DBDC59D34CE4CFB3950C0", item checksum = "922DA12AE1E3D8856695745C4D2830D2"., update "<Removed> Error Unable to process update.
When this error occurs no updates get made to the table.
I understand that row 1 can not be updated, however I would like row 2 (and all other rows where there is no conflict) to be updated. I would then like to be able to highlight in the form the rows that failed to update (And reload the data in them from the DB).
Is this something I can achieve using my own MRU procedure, or in another way?
Can anyone point me to a good example, tutorial or book showing how to do this.
Thanks!Thanks for the comments guys.
I have solved my issue in two different ways. Way one was not so clever, but worked, involving writing my own process for handling multi-row updates and would allow a user to fill in data for multiple rows (say 10) and have only the row with changed data rejected. V2 takes a very different approach, it uses Javascript, AJAX and the DOM model of the form to check when data is changed / updated by the user. Essentially, when a user enters an updateable form element, a AJAX request checks if the data has been changed. If it has, the value in the form is updated, and the color changed to blue to alert the user. When the user updates the data item, and AJAX request posts the new value to the database, where it is inserted. I had to build a bit of a framework to make this useable, and have to use dynamic sql in the database packages, but it work really well for what my users need! There are limitations (Currently it only supports date fields, text fields and drop down lists) but it works for me. It also involves traffic back and forth with the server each time a user moves the focus to a new form element, but it is a very light request and the work to do the select / updates in oracle is all based on a primary ke, so is ver quick.
Solution 1: (Would need to be made much more elegant):
1: Create a new text Item called P5_MESSAGE (To display error / success messages)
2: Create a new process:
DECLARE
l_cks wwv_flow_global.vc_arr2;
j pls_integer := 1;
vUpdatedCount number := 0;
vErrorCount number:=0;
vMessage varchar2(4000):='';
BEGIN
select wwv_flow_item.md5(firstname,lastname,age) cks
BULK COLLECT INTO
l_cks
from VA_TEST1 ;
for i in 1..l_cks.count
loop
if htmldb_application.g_fcs(i) != l_cks(i) then
-- Log error
vErrorCount:=vErrorCount+1;
vMessage:=vMessage||'Could not update row with ID:' || htmldb_application.g_f01(i) || '. This data has been updated by another user since you retrieved the data.<br>';
else
-- Do insert
vUpdatedCount:=vUpdatedCount+1;
update VA_TEST1
set
FIRSTNAME = replace(htmldb_application.g_f02(i),'%'||'null%',NULL)
,LASTNAME = replace(htmldb_application.g_f03(i),'%'||'null%',NULL)
,AGE = replace(htmldb_application.g_f04(i),'%'||'null%',NULL)
where ID = htmldb_application.g_f01(i);
end if;
end loop;
:P5_MESSAGE := vMessage;
end;
Note, this currently updates every row, even if the data is unchanged, this could be fixed by comparing the checksum of the data to be inserted with the checksum of the data in the table, if the same then no need to insert.
Solution 2:
Too complex to explain in detail here, if you need to implement this then let me know. -
Multi-Row Update form with wrapped fields
Hi,
I have a multi-row update form with too many fields to fit on the screen without having to scroll. Is it possible to wrap the extra fields onto a 2nd line.
So each DB record will actually span 2 srceen rows and fit nicely into my browser ??
Thanks for any help,
BrandonIt is possible, but would require some serious work on the report template, to create a custom row template.
I started to do this at http://htmldb.oracle.com/pls/otn/f?p=24317:191 but realized that it is hard work. Also, where would you show the headings for the second part of the row (split onto the next line)?
Instead, I would use the Show/Hide columns technique (client-side scripting) to reduce the number of columns shown. Search for it on this forum. Carl and I have some good examples out there. -
Popup window for tabular form row edition
To edit existing or new rows in a tabular form (page 1), I would like to open a popup window (page 2) with fields mirroring original tabular form fields. So, some basic data can be viewed/typed in the tabular form and the whole of the record data are viewed/typed on a separate popup form.
On opening popup, I pass a tabular form's current line number (filled with up to three zeros on the left).
When the user clicks on OK button on popup page, data will be put to the corresponding tabular form row. That should allow me to get /set tab form data from popup using following syntax:
opener.document.getElementById('f04_' + line).value
However, when I call data-initialization javascript function on onload of the popup form, popup fields to be filled are not rendered yet. At which point (and how) could I call this javascript initialization function?
Another question. With Firebug Inspector, I see that right in front of each tab form data tag, there is a "label" tag with the name of the column as it was defined in report attributes. As long as I have a information, opener.document.getElementById, what HTML/Javascript syntax should I use to get to this label tag?
IgorOK, the first part of question is OK now. Simply, I was putting a javascript code calling my initialization predure in the HTML Body Attribute section of the page, instead of simply writing there: onload="initFunction();"
The second one stands still: once I have a tabular form's element id like f20_0003, how can I get to the symbolic name, e.g., "FIRST_NAME", that is in the label tag in the same table cell? -
I have created a tabular form using the wizard. This form will show three columns (and in addition a checkbox). I would like this form to be updateable in only certain instances. Because of that, I select the columns twice. I make one of them updateable, and the other read-only. Then I have a conditional display for the columns, so that the updateable columns are shown if a status variable in my page is 'EDIT' and the read-only columns are shown otherwise.
The problem is that the multi row update does not occur. If I show one of the read-only columns when in the edit mode, the update is done. Also it is executed if I show one of the editable fields when the page is not in edit mode. But when I show only the editable fields in edit mode, and only the read-only fields when in read-only mode, the process is not run.
What can I do about this? Why doesn't the multi row update occur?An alternative is to control the updates by controlling the buttons. Only show the submit/update button if the status on the page is "EDIT".
-
Hello Everyone
I get the following error when attempting to perform a multi row update. Is anyone able to advise what the issue is?
Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "F71A42E70B86E7C8A14343633169264E", item checksum = "43A7146FE322237B683C4139D66E4DC5"., update "CSS_PRODUCTIVITY"."CENTREDATAASSOCIATIONS_TEST" set "MONTH" = :b1, "TM1_PREMISE_NAME" = :b2,hi oolite
i can't help you with your problem
but i have one suggestion
i don't know whether you created your tabular form with the wizard or manually
when you use the wizard
i would suggest that you try to build a tabular form manully
in fact it is a little bit more work but i think all what you have done by yourself
is more transparent and errors should be found easier
other suggestions take a look
Error in mru internal routine: Error in MRU
Error in mru internal routine
or search for error on mru
sorry that i can't tell you more -
How can i add rows in a tabular form
Hi,
How can i add rows in a tabular form with out updating in database and after adding the rows one by one and after filling the data then iwant to submit them all at once.Please help me on this.
ThanksHello Leandro,
In the Add_Rows page process, there is a box for "Number Of Rows". Change that value and you change the number of rows that get added. The default is 1.
Don.
You can reward this reply by marking it as either Helpful or Correct :) -
Unable to delete row(s) from tabular form
Hi!
I created report with row selector, when I select one row I get tabular form regarding to the selected row from report. I can insert and update data from tabular form, but I have problem with deleting them. Error I get is ORA-01403: no data found (Row 207589)My tabular form is created by wizard and primary key is managed by database rowid, I use apex 4.1 an 10g database.
Do you know for any solution for my problem?
Regards,
drama9346
Add:
For creating report and tabular form I use code and suggestion from this thread: {thread:id=2490862}
Edited by: drama9346 on 28.1.2013 1:51Hi,
I tried everything I know and I didn't solve my problem.
Can anyone give me some clue?
Regards,
drama9346
Add:
I solve my problem.
Edited by: drama9346 on 29.1.2013 1:52 -
Why is it necessary to include the if statement in the below multi-row update process?
I spent a large amount of time puzzling over this.
Thanks!
Bill
for i in 1..htmldb_application.g_f01.count loop
if htmldb_application.g_f01(i) is not null then
update my_table
set
column_1 = (replace(htmldb_application.g_f02(i),'%'||'null%',NULL))
where id = htmldb_application.g_f01(i);
end if;
end loop;Hi Marc,
Here's my query with the key items in bold. There are no null values in the g.grid field (it's the primary key). Thanks.
Bill
select g.GRID,
g.FAANUM,
'<a href="javascript:submitDate(''' || g.grid || '''); ">' ||
decode(decode(g.date_sub_3, null, 1, null),
1, decode(g.date_sub_4, null, '-', to_char(g.date_sub_4, 'fmMM/fmDD/YY')),
decode(g.date_sub_4, null, decode(g.date_rec_3, null, '-',
(30 - trunc(sysdate - g.date_rec_3))
|| ' ' || decode(trunc((32 - trunc(sysdate - g.date_rec_3))/6),
6, '<img src="#FLOW_IMAGES#greenN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
5, '<img src="#FLOW_IMAGES#greenN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
4, '<img src="#FLOW_IMAGES#greenN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
3, '<img src="#FLOW_IMAGES#greenN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
2, '<img src="#FLOW_IMAGES#yellowN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
1, '<img src="#FLOW_IMAGES#redN.gif" alt="You must submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">',
'<img src="#FLOW_IMAGES#past.gif" alt="You failed to submit this by: ' ||
to_char(g.date_rec_3 + 30,'fmMM/fmDD/YY') || '">')),
to_char(g.date_sub_4,'fmMM/fmDD/YY'))) || '</a>' "DATE_SUB",
g.DATE_REC,
g.REC_BY,
g.GRIEVANT "Grievant",
'<a href="f?p=&APP_ID.:9:' || :APP_SESSION || '::::P9_GRID:' || g.GRID || ' target="_blank">'||substr(g.topic,1,20)||'..</a>' "Topic",
y.word,
'<a href="f?p=&APP_ID.:9:' || :APP_SESSION || '::::P9_GRID:' || g.GRID || ' target="_blank"><img src="#FLOW_IMAGES#view2.gif" border="0"></a>' "VIEW",
g.reply_by,
g.natca,
trunc(g.reply_by-sysdate + 1,0) "Days",
g.grid "Notes",
null "Withdraw",
(select count(*) from gr_blob_intersect where grid = g.grid) "NumAtt",
decode(g.article, 0, 'E', 1, 'U') "Type_2",
'<a href="f?p=&APP_ID.:29:' || :APP_SESSION || '::::P29_GRID:' || g.GRID || ' target="_blank"><img src="#FLOW_IMAGES#xxx.gif" border="0"></a>' "VIEW/XXX",
htmldb_item.hidden(1,g.grid) || htmldb_item.text(2,g.arb_no,6) "Arb No",
htmldb_item.select_list_from_query(3, g.approval, 'select distinct text d, aid r from gr_approval order by aid',null,'NO') "Approval",
htmldb_item.text(4,g.advocate,6) "Advocate",
htmldb_item.date_popup(5,null,g.date_arb_sched,'DD-MON-YY',8) "Arb Date"
from GRIEVANCE g, yesno y
where y.id = nvl(g.ORAL,0)
and g.gr_status = 4
and (g.facility_id in (select id from gr_facility_lookup where region_id = (select f.region_id from gr_emp g, gr_facility_lookup f where upper(username) = :APP_USER and g.facility_id = f.id)) or g.facility_id = 3)
and g.status_id = 1
order by g.reply_by_4 -
About Multi Row Update...
APEX support Multi Row Update, but it is only support have two or fewer columns making up the primary key. now i want to use 3 columns as primary key to update datas, i how to implement it in APEX? thanks
· Table Owner: The schema name for the owner of the table.
· Table Name: Enter the table name or view. MRD’s and MRU’s can only dynamically build SQL statements for a single table or view.
· Primary Key Column: This is the first column of the primary key for the table. It is used for building the WHERE clause for the dynamic statement.
· Second Key Column: This is the column name for the second database column making up the primary key for the table. The MRU and MRD processes can only be used for tables that have two or fewer columns making up the primary key.
Edited by: user8016603 on 2011-3-14 上午1:51check {message:id=9369070}
-
More than one multi row update region on one page - how ?
Hi.
I have a page on which i want to use two multi row update regions ( updateable report with three buttons like new/delete/save ).
But i do not find a setting for the MRU-Process oder "Add-New-Line" Process that lets me reference this process to a specific region.
The problemm is, that after adding the second region to the page, the "Add-New-Line" - process only adds the new line to the second region and not to the first region anymore.
How can i make two processes where one adds a line to region1 and the second adds to region2. Same question is with updates too. How can i say that process on updates the changes in region1 and the other process updates the changes in region2 ?
Thanks for help.
greetings
berndUnfortunately, the builtin MRU process supports only 1 updatable region per page.
-
Conditional Select List in a Report maintained using a Multi Row Update
I have a SQL Report that is maintained with a "Multi Row Update" process. One of the columns needs to be ether a "Select List" based on a named LOV or just "Text" (Read Only) based on the value in the column. I have the UI working using a case statement and apex_items in me SQL but the Report Column is not marked "Edit" and the "Multi Row Update" process just ignores changes.
Any help would be great!Just curious, why is the first parameter to in third TEXT_FROM_ITEM invocation NULL instead of 20? Also check your first parameter in your ELSE. Shouldn't it be a global number as well?
Did you try adding a hidden item to your SELECT statement? Something like:
(case
when CSSN.KTTR_BILL_STAT_UID = KT_UTIL_PKG.get_kttr_uid_from_ref_val('SESSION_BILL_STAT','SESSION_BILL_STAT_1') then
apex_item.select_list_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT_PRPR','','NO')
when CSSN.KTTR_BILL_STAT_UID = KT_UTIL_PKG.get_kttr_uid_from_ref_val('SESSION_BILL_STAT','SESSION_BILL_STAT_2') then
apex_item.select_list_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT_PRPR','','NO')
when CSSN.KTTR_BILL_STAT_UID is null then
apex_item.text_from_lov(20,'KTTR_SESSION_BILL_STAT')
else
apex_item.text_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT')
end) as KTTR_BILL_STAT_DISP,
apex_item.hidden(30,CSSN.KTTR_BILL_STAT_UID) MIRRORThen in either an Javascript onBlur event on KTTR_BILL_STAT_DISP or in a Page Process assign the value of KTTR_BILL_STAT_DISP to MIRROR.
Mike -
Link column from an interactive report to insert a row in a tabular form
Hi, I need your help, i'm new on APEX and i really need to make a "link column" from an "interactive report" to insert a row into a "tabular form".
I mean that when you click the "link column" instantly create a new row in the Tabular form with the information of the linked row on the interactive report. Its something like that.
I really appreciate your help.
Ricardo CapuzHi Ricardo,
You can use the following code as per your requirement (this is just an example),
(In this case IR report is in Page#1 and Tabular form is in Page#2),
On Page#1, Create a hidden item (i.e 'P1_ID')
IR Report query as like the below,
select empno,
ename,
job,
mgr,
hiredate,
sal,
comm,
deptno,
empno "copy"
from empUse the below JS code in Page HTML Header section,
function f_insert_row(pSub)
$s('P1_ID',pSub);
doSubmit('ADD');
Edit Report Attribute -> copy column -> Under Column Link
Link Text: Select your column name (i.e. #EMPNO#)
Target: URL
URL: javascript:f_insert_row(#EMPNO#);
Then create a process to insert like below,
BEGIN
insert into emp_test (select * from emp where empno=:P1_ID);
END;Process condition as * Request=Expression1* in Expression1 as 'ADD'.
At last, create a branch to Page#2, Check 'include process success message' and with the same condition as * Request=Expression1* in Expression1 as 'ADD'.
Thanks,
Lakshmi -
I am trying to use HTML directly in SQL statement for tabular form (see SQL below). When the tabular form runs it is not converting the HTML so it displays as this:
Manala<span style="color:blue;">pan</span>
Am I missing something?
select
"PK_ID",
"CODE",
decode(instr(upper(city_name),upper(:P3_SEARCH)),
0, city_name,
substr(city_name,1,
instr(upper(city_name),upper(:P3_SEARCH)) - 1)
|| '<span style="color:blue;">' ||
substr(city_name, instr(upper(city_name),upper(:P3_SEARCH)),
length (:P3_SEARCH))
|| '</span>' ||
substr(city_name, instr(upper(city_name),upper(:P3_SEARCH)) + length(:P3_SEARCH) )) "CITY_NAME",
"STATE_CODE"
from "#OWNER#"."ZIP"
where upper(city_name) like '%' || upper(:P3_SEARCH) || '%'Right. The HTML is correct but the only way it will display right is when I changed the field attribute to 'Standard Report Column'. Unfortunately, that removes the field from being a text field (input).
-
Add row button on tabular form works from time to time
Hi!
we have two environments (dev & prod) with 10gR2 and APEX 3.2.1.00.12 (installed from one and only setup file)
we have developed application on dev and moved it to prod,
and on prod it was discovered that - from time to time (not always) -
when you press 'add row' button on tabular form,
tabular form does not display new record on the page,
if number of records exceeds number of records allowed to show
(i.e. with 10 records maximum it works fine when you add records from 1 to 10 and can't add record 11)
but - interestingly - increases number of rows in pagination by 1
(e.g. "rows 10-20 of 35" changes to "rows 10-20 of 36").
on dev this tabular form works correctly.
what is it and how to heal it?..
I recall I had same issue in prior releases (3.0 - 3.1), is it known issue?It seems to be true:
- if there is ascending order on columns which fields are null in new line (have no default value), new row is visible in current "pagination" page
- but if there is DEScending order OR ANY sort order is set on columns which fields are NOT null in new line (have default value), new row is NOT visible in current "pagination" page
thank you!
Maybe you are looking for
-
Installing Sql Server 2012 Enterprise edition on Windows 7
Hello, I have a desktop with 1 TB Hard Disk and 8GB RAM. It has Windows 7 installed. I want this to be used as staging server at my work. I installed the SQL Server 2012 Enterprise edition. While installing I used service accounts as default when pro
-
Fan speed problem Power Mac G5 Dual 1.8 GHz PowerPC - please help
Please HELP, I have a fan speed problem with my Power Mac G5 Dual 1.8 GHz PowerPC This is a NOT an Intel machine. I am running Mac OS X v10.5.8 Power Mac G5 - PowerMac 7,2 - Power PC 970 (2.2) - 1.8 GHz with 2 CPUs - L2 Cache (per CPU) 512 KB - Memor
-
my imac m5521 has a ? in the center of the screen when its turned on. how can i get past it & make my computer function?
-
Not able to connect to admin server through WLST
Hi, I am not able to connect admin server of machine1 though WLST from machine2. This is how i am trying to connect. wls:/offline> connect('weblogic','weterner1','t3://machine1:7111') Connecting to t3://machine1:7111 with userid weblogic ... Tracebac
-
Why can't I find the colon key (:) on my iPhone keypad? I need it as several sites I use require http://. It must be there somewhere.