Looping through row selector exonentially duplicating
Using Apex 4.2
Background
Created a Tabular Form based on a view. Removed all the default multi-row updates and deletions, buttons and processes.
I am using a tabular form because of the fact that I can gain access to a row selector.
The row data itself is all read only so in effect this is a report with a row selector.
This is because I can't find a way to select a row an interactive report, well I can and did but this was a work around.
Problem
I have created a button to process the selector to run the below code:
begin
kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f01(1)) ;
kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f02(1)) ;
for i in 1..wwv_flow.g_f01.count
loop
kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'i:'||i) ;
kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'WF ID:'|| wwv_flow.g_f02 (wwv_flow.g_f01.count)) ;
end loop;
end;
I just wanted to see what would be output. For one row this works fantastically and I can find the ID based on the row
When I select more than one row the loop run's through for the number of rows but then also runs for the number of rows selected.
So if I selected threee rows this above procedure would run three times, each times looping three times.
I have set the execution scope to: For Created and Modified Rows in the button condition that appears.
Required
I only want to loop through the selected rows once per button click
OR
Know which row I am currently looping through.
Really would appreciate some kind of input here.
I think the built in selector is making your life harder because the information that contains is 1,2,3,4,5. You then need to map 3 to the ID of your 3rd row.
So, if you check row 1 and 3, on submit, the row selector will have two rows, one with value of 1 and with with value of 3.
I would remove the selector, use and ID column that I can change to be Simple Checkbox (or whatever value you can use to uniquely identify it). Or add your own apex_item.checkbox(n, ID) to your SQL.
Then your loop on apex_application.g_f01.count (if that's the checkbox column) will only contain the elements checked and their values will be the ID that are checked.
All that said, here's a useful example from Denes Kubicek
http://apex.oracle.com/pls/otn/f?p=31517:95
Hope this makes sense
Thanks
-Jorge
http://rimblas.com/blog/
Message was edited by: jrimblas
Added link to Denes example page
Similar Messages
-
Upload XLS File, Loop through rows query a DB
What I would like to do is enable the user to upload an excel
spreadsheet with one column and many row of IP's. Then put the ips
in a list or array and loop through the list and query a table to
get the IPs that match the list.
Any help would be greatly appreciated.We have some similar apps except that, instead of uploading a
file, the users copy and paste the column into a text area. Then we
do this:
<!--- First, replace carraige returns (chr(13)) and line
feeds (char(10)) with commas --->
<cfset
hscnumbers=Replace(form.hscnumbers,chr(13)&chr(10),",","ALL")>
<!--- remove last comma, if commas exist (there may be
only one hsc number) --->
<cfif find(",", hscnumbers) gt 0 and right(hscnumbers, 1)
is ",">
<cfset hscnumbers = left(hscnumbers, len(hscnumbers) -
1)>
</cfif>
And then we have a list to send to the db. -
Loop Through Rows in SQL Report.
Hello Everyone,
I've been creating a very different application, and I've run into quite the roadblock.
Let me give you a breif about the problem.
I have a form that needs to be dynamic and thus is created at runtime.
I have used the APEX_ITEM and a SQL SELECT CASE to create a dynamic report.
For example if the DATATYPE column in my table says DATE, I create an APEX_ITEM.DATE_POPUP, if it says CHAR i create a textbox, and if a column called
LOV is populated APEX_ITEM.SELECT_LIST_FROM_QUERY using the number value of the LOV to query a List of Values from another table.
Now this brings me to say in a single column of the there could be different data_types. meaning the multi-row update functionality with apex will not work.
Getting the data to display is easy. However saving the updates is a different story.
Which brings me to my question. Does anybody know of way in which you can loop through each row in a SQL Report on APEX and assess each row individually.
I'd like to accomplish something like this
LOOP
MyUpdateProcedure(currentrow_id,currentrow_datatype, currentrow_value)
Go to Next Row in Report
END LOOP;
Pretty simple in theory? Do we have an APEX expert out there who could give me a hand with this?Codes,
It sounds to me like you could add a hidden field to tell you what you need to know in order to determine the column to update.
Assuming it was created using the parameter p_idx = 50 and contained the names you provided (eg DATA_DATA) and your primary key is created using p_idx = 1 then you could add the logic for the update into an on submit process something like so
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
CASE apex_application.g_f50(i)
WHEN 'DATA_DATA' THEN
-- run the update against the data column
WHEN 'CHAR_DATA' THEN
-- run the update against the char column
etc.
If the multi-type column is created with the apex_item api using p_idx = 2 then you just refer to it in the loop as apex_application.g_f02(i) and the primary key is apex_application.g_f01(i).
I hope this helps.
Greg -
How to loop through rows in datatable?
Hi,
I have a datatable component with a few columns bound to a database table but I have also added a new textfield column to the datatable. The purpose of this datatable is to present the user with a list of products from the database and then allow the user to enter a quantity value into the textfield for each product (ie datatable row).
This all works fine until i need to capture the quantity values the user has entered. It seems the datatable component can only provide the current row details. However what I want to do is when the user finishes entering the quantities for all the products they click a button and then I loop through each row in the datatable from start to end and find out what quantities were entered for each product.
I can find no documentation or threads on how to do this. It seems like a very basic concept but perhaps is not possible to achieve. Can anyone help?
Also I entered a default value of "0" in the value expression (ie text) property of the new textfield in the datatable but this value never appears (ie the textfields are always empty). However the text property seems to work ok for normal textfield components not within a datatable. Any ideas?
Thanks.thanks, I am able to iterate through the datatable rows now and get the values, however I still have one (actually two) big problem...
1. I cannot get the textfields to be prepopulated with a value when the page first loads. I have the text property of the textfield set to a value but this makes no difference, the textfields are always blank.
2. After a user enters values and clicks the button to calculate the page reloads and again all entered values are gone (ie the damn textfields are empty again). Is this normal behaviour for textfields within a datatable....surely not.
So, I added some code to my prerender method to specifically populate the textfields and although it loops through each textfield only the last textfield gets populated. I cannot work this one out. Datatables should be easy to work with, but like most things Creator turns an easy job into an impossible one.
Please help. -
Loop through values in rows to find faulty data
Hi all,
We have a column which is supposed to have values in increasing order.(If it doesn't comply with this rule, we want to discard the row). How do I loop through rows for a particular column, in SQL or PL.SQL?
Thanks.user12295995 wrote:
If it doesn't comply with this rule, we want to discard the rowNot sure what you mean. It looks like you want to get rid of duplicates. If so, use:
DELETE tbl WHERE ROWID NOT IN (SELECTMIN(ROWID) FROM tbl GROUP BY col)
/If you want to identify gaps, use:
with t as (
select 1 id from dual union all
select 2 id from dual union all
select 3 id from dual union all
select 4 id from dual union all
select 5 id from dual union all
select 11 id from dual union all
select 12 id from dual union all
select 13 id from dual union all
select 21 id from dual union all
select 22 id from dual union all
select 23 id from dual
select '[' || (prev_id + 1) || ' - ' || (id - 1) || ']' gap
from (
select id,
lag(id) over(order by id) prev_id
from t
where id > prev_id + 1
order by id
GAP
[6 - 10]
[14 - 20]
SQL> SY. -
Loop through a csv file and return the number of rows in it?
What would be simplest way to loop through a csv file and
return the number of rows in it?
<cffile action="read" file="#filename#" output="#csvstr#"
>
<LOOP THROUGH AND COUNT ROWS>ListLen(). Use chr(13) as your delimiter
-
How Do I get SSIS To Stop Looping Through Excel Rows After Last Populated Record?
I have a package that loops through many excel files. Each Excel File has about 5000 rows. My problem is that after the 5000th row SSIS keeps looping through all the rows after the last row. There are nothing in these rows. This is a complete bottleneck
of my package because it takes forever when doing this. How do I stop this?
ThanksAnother way is to specify the range in select statement which can be done in two ways
http://getsetsql.blogspot.in/2012/01/using-ssis-load-data-to-excel-sheet-at.html
http://sqlserversolutions.blogspot.in/2009/02/selecting-excel-range-in-ssis.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Loop through result set and delete row
so here is what I need -
I have a query that pulls rows from the Database through a stored procedure.(these are properties in an area)
Before I start looping through the query, I need to check the distance between my current location and the property. If it less than 5 miles, only then should I display that property. The distance in miles will be chosen while submitting the search form.
So is there a way to delete rows from the result set based on the criteria? Or
Is there a better way to accomplish this? I am using the the google api to get the latitudes and longitudes. The other issue to keep in mind is the load time.
ThanksYou can do this the easy way or the hard way. Depends on whether your condition that needs to be checked can be expressed in the form of a SQL where clause. If it can, then do what BKBK suggested, and use a query of query to create a new resultset that only has the rows from the original resultset that don't meet your condition.
If the calculation of the condition is more complex, then do a CFLOOP over the query and examine each row to see if you want to keep it or toss it. if you want to toss it, the delete that row - there is a function in CFLIB.ORG called querydeleterow that should help you. Or, you could just clear out the row's contents and then do the query of query as described in BKBK's post to create a new resultset that doesn't include the blank rows. -
How to loop through xml records from file without ROW , /ROW tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
-
How to loop through a single row of data?
What I'm trying to do is use a cursor to loop through a clob. When I create my cursor I get the an error telling me that the table does not exist. Which implies that I have an implicit cursor. Is there a way to get around this?
> How to loop through a single row of data?
By not looping as there is only a single row?
> What I'm trying to do is use a cursor to loop through a clob
Processing (looping through) a CLOB has nothing to do with a cursor.
> When I create my cursor I get the an error telling me that the table does
not exist. Which implies that I have an implicit cursor.
Incorrect. It simply means that
a) you do not have permissions to access that table from within the current context
b) it does not exist (e.g. you have misspelled the object name, you have not qualified it properly within the current scope, etc) -
Hi folks,
I have a table with multiple rows which each one of them contains one dropdown list.
In my code I want to loop through this table rows and check each dropdown list's selected-item.
How can I do this in code(JavaScript).
Thank you,
YairCheck this thread,
it has solutions for JavaScript ind FormCalc.
http://forums.adobe.com/message/3345384#3345384 -
How to loop through classic report rows?
Hi,
I have a page that has a classic report region. Can I somehow loop through the rows in the report result?
If I put a checkbox item in the query then using this works fine, but I would not like to add checkbox I just would like to loop through the records.
FOR I in 1..APEX_APPLICATION.G_F02.COUNT LOOP
Do something with record having checkbox item value APEX_APPLICATION.G_F02(i);
END LOOP;
TIA,
TamasAndy,
What I would like to do is to let the user click a report row, then navigate to a detail form page and display detailed information of the given report row. And should the suer decide to have a look at all the records, then let him/her click a next button on the detail form and display the next row in the report result on the detail form.
Thanks for the tip. if there is no other way, I will probably do this way.
Tamas -
JDev 10.1.3.4: How to properly loop through the rows of a VO?
Hi,
This is a newbie question. Using JDeveloper 10.1.3.4 I am trying to loop through the rows of a view object. I am sure that the VO returns the following rows in that order:
200809
200902
200906If I use this code (where termsOpen is the VO instance):
while (termsOpen.hasNext()) {
System.out.println(termsOpen.getCurrentRow().getAttribute("Term"));
}it proves to be an endless loop and I get "200809" printed on the console endlessly. The API says that hasNext() "does not move the current row". A book says that the pointer initially is at row 0. I wonder why it prints the first row. So the code is changed to:
while (termsOpen.hasNext()) {
Row currRow = termsOpen.next();
System.out.println(currRow.getAttribute("Term"));
}But now I get only the last two rows printed on the console, and do not get to see the first row:
200902
200906What's wrong?
Thanks for helping!
NewmanHi, Branislav,
Thank you for the suggestion.
I tried that also. When the code is
while (termsOpen.hasNext()) {
System.out.println(termsOpen.getCurrentRow().getAttribute("Term"));
termsOpen.next();
}I get only the first two rows and last row is dropped:
200809
200902To get all the three row, I end up using this code:
System.out.println(termsOpen.first().getAttribute("Term"));
while (termsOpen.hasNext()) {
Row currRow = termsOpen.next();
System.out.println(currRow.getAttribute("Term"));
}But that shouldn't be the way of doing the work. If I use a block of 50 lines of code to process each row, the code will have to be written once before the while loop and another time inside the while loop.
The book which says that the pointer starts at the row slot before the first row is found on the internet, on p.469. It makes sense to me that the pointer starts at row 0. But unfortunately the actual copy of JDev 10.1.3.4 I am using behaves otherwise.
Newman -
How to update records marked by [row selector] ?
Hello,
I have a small table (PK=record_id) from which I send mail to a user of informational reasons. At the moment I can only send all records in a mail, but I want to be more 'selective', send only marked records.
The table is shown in a APEX-report defined as an updateable report.
I added a column [record selector] to it, allowing me to put a mark before the record to be send.
I did not succeed however sending the user only the marked records....
I tried something like
BEGIN
-- Loop through the rows that have been checked.
FOR I IN 1..HTMLDB_APPLICATION.G_F01.COUNT
LOOP
SELECT record_id
INTO to_be_send_record
FROM meldingen_voor_postverzending
where HTMLDB_APPLICATION.G_F01(I) = 'Y' ;
-- place the record with record_id = to_be_send_record
-- into a mail (via a self-made package) ...
END LOOP;
-- send the mail (using HTMLDB_MAIL)
END ;
It looks as if the records marked are not selected, but I can't find the reasopn why.
Maybe the = 'Y' is not correct, but I also tried "is not null" , '!= NULL" and other things.
Can anybody help me getting opnly the checked records into the mail-body?
Thanks and regard,
Jan.Hi Jan,
try the following code:
DECLARE
vRow BINARY_INTEGER;
BEGIN
:p95_text := NULL;
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
vRow := apex_application.g_f01(i);
:p95_text :=
:p95_text
|| CHR (10)
|| vRow
|| '. '
|| apex_application.g_f02 (vRow)
|| ' / '
|| apex_application.g_f03 (vRow)
|| ' / '
|| apex_application.g_f04 (vRow)
|| ' / '
|| apex_application.g_f05 (vRow)
|| ' / '
|| apex_application.g_f06 (vRow)
|| ' / '
|| apex_application.g_f07 (vRow);
END LOOP;
END;The APEX row selector returns the row number of the selected row. Not the primary key or whatsoever. So you have to use that value to access the arrays of the other columns.
Hope that helps
Patrick
Check out my APEX-blog: http://inside-apex.blogspot.com -
SQL Query updateable report with row selector. Update process.
I have a SQL Query updateable report with the row selector(s).
How would I identify the row selector in an update process on the page.
I would like to update certain columns to a value of a select box on the page.
Using the basic:
UPDATE table_name
SET column1=value
WHERE some_column=some_value
I would need to do:
UPDATE table_name
SET column1= :P1_select
WHERE [row selector] = ?
Now sure how to identify the [row selector] and/or validate it is checked.
Thanks,
BobI don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
It should be like
<input id="..." value="" type="checkbox" name="fXX" >we are interested in the name attribute , get that number (between 01 and 50)
Replace that number in the code, for instance if it was f05 , the code would use
apex_application.g_f05
--i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.
Maybe you are looking for
-
Error when using byte array in web service model interface
Hello everybody, I'm using a web service model in my web dynpro application. The web service requires a byte array as import parameter. When starting the web dynpro application the following error occurs: com.sap.tc.webdynpro.services.exceptions.WDTy
-
Wrong House Bank defaulted in tx. F110
Hi Everyone, So here is a weird issue I am facing. I went live last monday with ECC 6.0. AP has been implemented as standard as it gets. I am running tx. F110 to pay four invoices, from four different vendors. Check lot "1" has been properly crea
-
Automatic 2nd line item in sales order
Hi All, We are using variant configuration. I have one requirement where if i input the first line item in sales order for a material, system should automatic input 2nd line itme of another material based on configuration mainatined. Please let me if
-
Hi, I have some data file exported from DB2. I ever tried to use the following command to do the data loading on isql*plus, LOAD DATA INFILE 'C:\tmp_0123\aba.del' APPEND INTO TABLE dclsuser1.aba FIELDS TERMINATED BY ';' (BANK_NUM, BANK_NAME, BANK_ABA
-
my iphone is in recovery mode