Fill multi row before insert
hello guys I want to fill a block with multiple rows before inserting the rows data are from 2 blocks in the form I tried to use next_record , down but they are all restricted here an example of what I want to do
I have block1 , block2 and block3 and I want to fill block3 with the first row of each block before inserting the data in the block3
what should I do?
Thanks in advance guys
But MRU and MRD.... where is Multi-Row Insert?
The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
I was thinking about adding an extra value and adding a trigger to do the inserting instead
Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
Something like
create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
create or replace trigger mytrig
after insert or update or delete on mytable
for each row
declare
l_action varchar2(1);
begin
if inserting then l_action := 'I';
elsif updating then l_action := 'U';
elsif deleting then l_action := 'D';
end if;
insert into mytable_hist
values
l_action,
version_no_seq.nextval,
nvl(:new.col1,:old.col1),
nvl(:new.col2,:old.col2),
nvl(:new.col3,:old.col3),
end;
/
Similar Messages
-
Multi Row Madness: Insert?
Hey Guys,
I've been hitting my head against a cobbled wall trying to figure this one out.
I'm creating a form that needs to support versioning - so instead of ever using an update the form always inserts a copy of the data into the database with an incremented version number.
Frustratingly enough the form requires a dynamic amount of parts - best editting and represented but a tabular form. But MRU and MRD.... where is Multi-Row Insert?
I've tried everything i can to load the information and then change the version - but doing this will result in a ORA-20001: Error in MRU as the data in database is different and cannot "update" the row for old records (when i just want it to copy with a new version number).
The tables work with a header table that had id and version attributes making a combined pk, and the parts table with id and version which references the header table, and a parts_id to uniquely identify itself.
Is there any suggestions on this issue? I was thinking about adding an extra value and adding a trigger to do the inserting instead - but i fear this approach may change the information in the current version (i'm not that familiar with oracle databases... so prefer to try to find a solution in apex).
I'm using 2.2.
cheers,
AlexBut MRU and MRD.... where is Multi-Row Insert?
The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
I was thinking about adding an extra value and adding a trigger to do the inserting instead
Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
Something like
create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
create or replace trigger mytrig
after insert or update or delete on mytable
for each row
declare
l_action varchar2(1);
begin
if inserting then l_action := 'I';
elsif updating then l_action := 'U';
elsif deleting then l_action := 'D';
end if;
insert into mytable_hist
values
l_action,
version_no_seq.nextval,
nvl(:new.col1,:old.col1),
nvl(:new.col2,:old.col2),
nvl(:new.col3,:old.col3),
end;
/ -
Conditional multi row Table insert
Hello,
I've a multi insert table, with 1 new row (_1B). In some cases I don't want a
new row, because there are enough rows created, how should I prevent the new row on the iterator?
Anyone an idea?
Regards,
Ruben SpekleWouldn't it be easyer to just omit the _1B if your condition occurs?
model = "${ ui:conc ( 'yourtablename' , ui:cond ( yourcondition , '_1B' , '' ) ) }"
Anton -
Right way to delete row before insert
I create a new row with method of ViewObject.
Row row = viewObject.createRow();Then I want to delete this row. I found there are 4 methods. Which is the right answer?
//1.
row.remove();
//2.
row.refresh(Row.REFRESH_REMOVE_NEW_ROWS);
//3.
row.refresh(Row.REFRESH_FORGET_NEW_ROWS);
//4.
row.removeFromCollection();Thanks,Timo, we're having a problem when deleting as you describe, maybe you can offer some advice?
We have a button to delete a row from an editable table, this is set to immediate=true (obviously the user should be able to skip validation when doing a delete). After deleting, if the user then clicks another button to add a new row, the values from the deleted row show in the new row :(
If we set immediate=false this seems to fix the problem, but we then get the undesirable side effect that the user has to make sure all the values in the row are correct before it can be deleted (because the validation is firing). The user experience becomes a bit strange. -
Resultset after insertion is the same before insertion
hi guys, i get an updatable resultset from a connection then used it to insert a new row but the result set doesn't chane after insertion, i mean the no of rows before insertion is the same after insertion and also the data, this is the code prove what i say
int currentRow = resultset.getRow();
display(resultset);
resultset.moveToInsertRow();
for (int i = 0; i < fields.size(); i++) {
updateCurrentRow(resultset, fields.getField(i));
resultset.insertRow();
display(resultset);the display function body is
int currentRow = res.getRow();
res.first();
while (true)
System.out.println("CountyCode= " + res.getInt(1));
System.out.println("CountyName= " + res.getString(2));
if (!res.next())
break;
res.absolute(currentRow);Please help me
N.B.
the type of resultset after creation it is res.getConcurrency() == ResultSet.CONCUR_UPDATABLE?????
Thanks for your effortsthnaks for your reply, but when i used
ownInsertsAreVisible() method; returned true, that is
mean that the driver and DB supports the updating of
reultset after insertion. but this is not real at my
case? that was strange. if you have any comment please
do,just checking the row is in fact being inserted into the database? i mean you can't see it right away but you can see it later right?
if the row is being inserted and the ownInsertsAreVisible() returns true then there are two possible scenarios.
1) the cursor type of your result set does not support that method, meaning the method is true in some cases but not yours... for example your query might have a join or something which makes it not possible for the result set do be fully cognizant of changes. and sometimes there are database specific cursors that have to specified as part of your query in a proprietary way to get the "right" cursor. you will need to investigate the docs for your database to figure out if any of this is true.
2) the meta data is lying. -
Multi-row insert in master-detail tables
Hi, I'm using jdev 10.1.3.2 with jheadstart and my problem is:
I hava a master-detail structure, both are tables and my goal is that I want multi insert (exactly 3) in master and detail table when user makes new order(some business scenario). I cannot create rows in master or detail VO by overriding create() method because its entities have complex primary keys and some part of this key is populated by the user with lov. So I set in jhs new rows to 3 and checked multi-row insert allowed but the problem is that overall I can only create rows in master table after I submit form. I want to create row in master table and fill rows in detail table, and after that I want to have opportunity to create second (or even third) row in master table and fill rows in detail table.
thanks for help.
PiotrSee JHS DevGuide: 3.2.1. Review Database Design:
If you are in the position to create or modify the database design, make sure all
tables have a non-updateable primary key, preferably consisting of only one
column. If you have updateable and/or composite primary keys, introduce a
surrogate primary key by adding an ID column that is automatically populated.
See section 3.2.4 Generating Primary Key Values for more info. Although ADF
Business Components can handle composite and updateable primary keys, this
will cause problems in ADF Faces pages. For example, an ADF Faces table
manages its rows using the key of the underlying row. If this key changes,
unexpected behavior can occur in your ADF Faces page. In addition, if you want
to provide a drop down list on a lookup tables to populate a foreign key, the
foreign key can only consists of one column, which in turn means the referenced
table must have a single primary key column.
Groeten,
HJH -
ADF Editable Table : CANNOT Insert Multi Rows , Please hellppppssss
Hi All,
Our customer requirement is being able to insert Multi Rows in an Editable Table and submit ALL of them with just one Click ?
Is it Really Possible ?
I have tried, even I can insert three Empty Rows and Fill them all with values, when I press Submit ONLY one row will be submitted, the other TWO will become BLANK again, is this my code is wrong ?
Or this is limitation of ADF Editable Table ?
Here is my codes, I have tried two ways, all same problem :
(1) public String create_action() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("Create");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
return null;
public String myCreate_action() {
create_action();
create_action();
create_action();
return null;
(2) public String createMultiRows() {
DCBindingContainer dcbc = (DCBindingContainer)getBindings();
//get iterator binding
DCIteratorBinding ib = (DCIteratorBinding)dcbc.get("DeptView1Iterator");
// get viewobject
ViewObject vo = ib.getViewObject();
System.out.println(vo.getCurrentRowIndex());
vo.clearCache();
int currentRowIndex = vo.getRowCount() -1;
Row row1 = vo.createRow();
row1.setNewRowState(Row.STATUS_NEW);
vo.insertRowAtRangeIndex(++currentRowIndex, row1);
Row row2 = vo.createRow();
row2.setNewRowState(Row.STATUS_NEW);
vo.insertRow(row2);
Row row3 = vo.createRow();
row3.setNewRowState(Row.STATUS_NEW);
vo.insertRow(row3);
return null;
Please help... I am stuck ...
Thank you very much,
xtantoXtanto,
Could you try changing
bindings.getOperationBinding("Create");to
bindings.getOperationBinding("CreateInsert");in your first example to see if it fixes your problem?
Regards,
John -
Issues in Table with Multi-Row Insert
I have created a master detail screens using jheadstart on 2 separate pages, Master in the Form layout and detail in the Table Layout with multi-row insert, update and delete flags ON. Have set the New Rows count = 2.
Issue 1
If I try to delete any existing rows, it gives error for new rows saying value is required for the mandatory fields. It should just ignore the new rows if I have not updated any values for any attributes in the those row(As it does for non Master-Detail Table layout). I guess this might be happening because the jheadstart code is setting the foreign key for new rows the detail, but not resetting the status of the rows back to INITIALIZED.
I also noticed that the create() of underlying EO is getting called for those blank rows when I click on 'Save' button, even if I have not changed any data in those rows.
Issue 2
When I try to select the new rows also for deletion, I am getting a '500 Internal Server Error' with following stack trace... This is also happening for normal (non Master-Detail) Table layout.
java.lang.IllegalStateException: AdfFacesContext was already released or had never been attached. at oracle.adf.view.faces.context.AdfFacesContext.release(AdfFacesContext.java:342) at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:253) at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
Issue 3
I have put some validation code in the validate() method in the MyEntityImpl.java class.
The validate method seems tobe getting called lots of times, in my case 20 times, where the new rows are just 2.
Environment:
Jdeveloper 10.1.3, JHeadStart 10.1.3 build 78, Windows XP
thanksThanks for the reply.
Issue 1:
What I have observed that in case of multi-row select enabled tables, the blank rows do not have any data. This is because the EO's create() method is called only when we post the data using 'Save' button. Thus the Foreign Keys are also not setup. This is a correct behavior since create() and FK setups etc should get done only if the user has inputted any value in the new rows and thus intend to insert new data into the table.
I am able to find the exact cause of this issue. It is happening because in the details table, I have a column which needs tobe shown as checkbox. Since we can only bind checkbox to an Boolean attribute in VO, I have created a transient attribute of type Boolean, which basically calls the getter/setter of actual attribute doing the String "Y"/"N" to true/false conversion. Here is code for the transient attribute getter/setter
public Boolean getDisplayOnWebBoolean() {
return "Y".equals(getDisplayOnWeb()) ? Boolean.TRUE : Boolean.FALSE;
public void setDisplayOnWebBoolean(Boolean value) {
if(Boolean.TRUE.equals(value))
setDisplayOnWeb("Y");
else
setDisplayOnWeb("N");
Now when I click on the "Save" button, the setter for the boolean field is getting called with the value = false and this is resulting into the row being maked as dirty and thus the validation for the required attributes is getting executed and failing.
Issue 2:
Confirmed that correct filter-mapping entries are present in the web.xml.
Now when I select the new blank rows for deletion and click save, following exception is thrown:
java.lang.ClassCastException: oracle.jheadstart.controller.jsf.bean.NewTableRowBean at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.getRowsToRemove(JhsCollectionModel.java:412) at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.doModelUpdate(JhsCollectionModel.java:604) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.processModelUpdaters(JhsPageLifecycle.java:541) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.validateModelUpdates(JhsPageLifecycle.java:571)
thanks - rutwik -
How to Commit before Insert Row when Press Create Insert Button ?
Hi all;
I'm Using JDev 11.1.1.2.0
How to Commit before Insert Row when Press Create Insert Button in ADF11g?
<af:commandButton actionListener="#{bindings.CreateInsert.execute}"
text="CreateInsert"
disabled="#{!bindings.CreateInsert.enabled}"
id="cb8" />
best regards;You need to do a custom method eather in managed bean or in Application module to do that.
in managed bean it would be something like:
public void CommitAndInsert(ActionEvent actionEvent) {
OperationBinding opCommit = ADFUtils.findOperation("Commit");
opCommit.execute();
OperationBinding opCreateInsert = ADFUtils.findOperation("CreateInsert");
opCreateInsert.execute();
In page bindings Commit and CreateInsert must exist
then the button actionListener will be
<af:commandButton actionListener="#{backing.CommitAndInsert}" -
Master-Detail Multi-Row Insert
Im still using Oracle forms 6i. How do we create here in ADF for the transaction in master-detail operation specially in inserting multi-row in detail. In forms we can use key-next item trigger next_record for new record transaction for drugs or we can use bar code scanning to insert new records & automatically go to next records waiting for another input...
pls help me i want to upgrade & pls sorry for my english...
just want this adf behave like forms in terms of master-detail transaction entry...
i appreciate if someone can help me or give me demo file to download & play with it...
Edited by: user8983555 on Nov 10, 2010 10:30 AMtnx for the fast reply..
im new with jdeveloper and no knowledge in java or html. im concentrated in pl/sql , forms 6i.We still using this until now in character base in unix environment but some module in gui mode.im working in hospital which is complete informations sytem (stock,pharm..etc...gl...) which in bulk transactions specially patients outclinic & inpatients charges.now we have also this reservations system for out clinics thats the reason im like to develop for in a web that a patient can reserve on line and i dont like running our application in different front end (forms 6i &jdeveloper).
(now currently checking form10g & just set up AS10g which is working.can deploy and connect,LAN). but im very interested in ADF when i see the demo on Oracle website.
now our company pplanning to change our application to power builder whiich is not good in performance regarding in hadling big databases (slow query,needs burst AS...) thru to the demonstration of the
apllication vendors.
im very glad if you can help. can you post a links or demo file to do this as you said....(You can replicate the code in the button in some other event on your page, for example when the value of the last field in the row is changed.
It all comes down to the question of when you actually want to create a new row, and in that event you call the createInsert method.)
this is my only problem now to make this master-detail multi-row insert like ora form.
again sorry for my english... -
In php & mysql I am used to being able to do multi row inserts into a table using;
INSERT INTO table (column1,column2) VALUES (val1,val2),(val3,val4)
Is there any Sqlite equivalent? I need to populate around 100 rows on first run of a mobile application.
Thanks,
PeteIf what _spoboyle recommends doesn't work in AIR and if you haven't already, look into the SQLConnection.begin() and commit(). It seems at least you can group your SQL transactions.
-
I have read a few posts that mention a multi-row-insert but I can't find it.
There is a multi row update and a multi row delete.
I am using html db 1.6. We will be upgrading after we get this version of our app up and running, but don't want to take time out for the upgrade right now.
Is multi_row_insert new to Application Express 2.0?
Thanks,
GregoryNo, the multi row insert is not new to 2.0
The builtin MRU processes handle multi-row updates and multi-row inserts. However, the default Add Rows process that the wizard creates on a tabular form does create only 1 blank row when you click the Add Row button. To increase this, just open the Add Rows process page and change 1 to a different number. -
Multi-row uipdate with an insert into another table [I think]
Folks,
I'm trying to get a multi row region with a checkbox against each row. When a user checks a box I want to insert a corresponding row into another table. So I've tried to simplify the questions and distill the problem down using the EMP table.
So, here goes:
I have table EMPS, which looks like this:
EMPNO Number
FIRSTNAME Varchar2(9)
LASTNAME Varchar2(10)
HIREDATE Date
I have table EMP_CANDIDATES, which looks like this:
EMPNO Number
SELECTION_DATE Date
NOTES Varchar2(53)
- I want to create a multi-row region based on EMPS, with a checkbox on each employee row.
- The user should be able to select any number of employees in the region and then press submit.
- on-submit there needs to be a process, which inserts a record into EMP_CANDIDATES for each checked employee.
I've tried pre-populating a collection with the EMPS records and using apex_item.checkbox to produce a checkbox, using this code:
=============
if apex_collection.collection_exists(p_collection_name=>'EMPS') then
apex_collection.delete_collection(p_collection_name=>'EMPS');
end if;
apex_collection.create_collection_from_query(
p_collection_name=>'EMPS',
p_query=>'select
p.empno,
p.hiredate,
p.firstname,
p.lastname,
null selection
from emps p');
=========
I can create a report region on this using tthe following SQL:
select c001 empno
, c002 hiredate
, c003 firstname
, c004 lastname
,apex_item.checkbox(1,c005) selection
from apex_collections
where collection_name ='EMPS'
======
So how do I now get a MRU that will insert a row into EMP_CANDIDATES for each checked row in my region? Or have I gone about this the wrong way?
TFH
DerekHi Derek,
Firstly, your checkbox should be on the c001 field as this is the one that contains your empno.
Then, you need a page process that can be triggered by a button. The process should be set to run "On submit (After computations and validations)" and the PL/SQL code would be something like:
DECLARE
v_empno NUMBER;
BEGIN
IF HTMLDB_APPLICATION.G_F01.COUNT = 0 THEN
raise_application_error(-20001, 'Please select at least one employee!');
END IF;
FOR i IN 1.. HTMLDB_APPLICATION.G_F01.COUNT LOOP
v_empno := TO_NUMBER(HTMLDB_APPLICATION.G_F01(i));
INSERT INTO EMP_CANDIDATES VALUES (v_empno, whateverdate, whatevernotes);
END LOOP;
END;
This will firstly count the items that have been ticked - if there aren't any, the user gets an error message. If there is at least one item ticked, the code will loop through these, get the empno relating to the ticked box and insert a record into the emp_candidates table. Please note that no account is taken here of any validation on this second table - if you need to ensure, for example, uniqueness of records in this table, you will have to update the above to perform this validation.
Regards
Andy -
Multi row insert with checkboxes and textfield
i'm trying to build a multi row insert on tabular form.
i have checkboxed to choose the rows which i want to insert.
in this row i have to insert a value into the textfield.
but when i'm looping my checkec checkoxes my prcedure always takes the first textfields in my report.
what's going wrong?
select apex_item.checkbox(30,ar_id, 'class="checkThis"') as ar_id
,apex_item.display_and_save(31,ar_nr) as ar_nr
,ar_name
,apex_item.text(32,null) as Menge
from ar
FOR i IN 1.. APEX_APPLICATION.G_F30.COUNT LOOP
insert blabla (st_profil_id, ar_id,menge)
values(:P5_st_profil_id,APEX_APPLICATION.G_F30(i),APEX_APPLICATION.G_F32(i));
end loop;Hi,
Please read the following
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_app.htm#CHDGJBAB
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_item.htm#CHDDCHAF , especially the Creating an On-Submit Process.
Cheers, -
Is there any way of providing Multi Row Inserts in a single region.
I am looking for a way to add several records at once in a table format, much like the multi row update functionalty.
Is this possible?Can you use an OUTPUT clause? See examples
MERGE INTO dbo.Customers AS TGT
USING dbo.CustomersStage AS SRC
ON TGT.custid = SRC.custid
WHEN MATCHED THEN
UPDATE SET
TGT.companyname = SRC.companyname,
TGT.phone = SRC.phone,
TGT.address = SRC.address
WHEN NOT MATCHED THEN
INSERT (custid, companyname, phone, address)
VALUES (SRC.custid, SRC.companyname, SRC.phone, SRC.address)
WHEN NOT MATCHED BY SOURCE THEN
DELETE
OUTPUT
$action AS the_action, deleted.custid AS del_custid, inserted.custid AS ins_custid;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Maybe you are looking for
-
After my Dell studio1535 running Ubuntu 11.04 switches to screen saver and then blanks the screen to save power I canl bring back my desktop, but not accept any keyboard or mouse clicks. It will allow courser movement only. The only solution is to po
-
How can I remove google custom search bar from about:newtab page
When I open Firefox or a new tab I have it set to about:newtab which is great and all. Just recently I noticed a Google search bar on the new tab page though, that it immediately sets my cursor to. I prefer typing in the normal address bar at top. If
-
Why have "All Day" events moved forward by 24 hours when syncing from my iPhone to iMac?
When I syncd my calender from my iPhone 3Gs to iMac for the first time, it moved all the events entered as "all Day" forward by 1 day on iCal. It didn't do that to events with a set start and finish time on a day.I have checked the date/time settings
-
Mac OS 10.5.4 broke printing from iMac, and MacBook Pro to Brother ML-1740
I have had my five Macs (iMacs, Mac Book Pros, Mac Books) all printing via an Air Port Express to a Brother ML-1740 Laser Printer. As each one downloaded and was upgraded to 10.5.4 they lost the ability to print to this printer. They can still see it
-
I have a HP machine with this mother board. I think it is running bios 5.16. I am trying to find the 5.22 update as i am looking at upgrading the CPU to a e8400. I am running windows 7 32bit and the only update i have been able to find is for VISTA.