Java documentation / iterate through row values

Hi there,
I have a OAF page that I need to edit and didn't originally create. The page shows record details and each row has an updatable field that the user can enter values and submit. i need to be able to iterate through what has been entered and make updates from there. (Some of this functionality is currently coded but it is not working correctly)
Can someone please point me in the right direction for where I can find documentation/code samples on how/best way to write this code? (Am I on the right track with RowIterator?) I have the Users' Guide for the jDeveloper RUP version but I think I need additional references. We are on RUP7. I'm sure there's a java guide somewhere, but I don't even know where or under what to look!
Thanks for helping a complete novice!!
Janel.

Why do you need to loop through the result set? This is very easy to do with simple set based SQL:
DECLARE @Status INT = 0;
DECLARE @tbl table (BoolCol bit);
insert @tbl values (1), (null)
SELECT
@Status = CASE WHEN COUNT(
CASE WHEN BoolCol = 0 THEN 1 ELSE NULL END) > 0 THEN 1
WHEN COUNT(
CASE WHEN BoolCol = 1 THEN 1 ELSE NULL END) = COUNT(*) AND COUNT(*) > 0 THEN 2
ELSE 0 END
FROM @tbl;
select @status
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

Similar Messages

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

  • Iterate through table rows

    Hi Experts ,
    JDEV 11.1.2
    how can we iterate through Richtable rows one by one......?
    if we have a 5 rows in a table , i need an iteration thorugh all 5 rows in order to check attribute values......how can i implement this?
    please give me some rference code...
    PMS
    Edited by: pms on Apr 4, 2012 2:40 PM

    Hi
    getAllRowsInRange() method in the DCIteratorBinding will help you to get the number of rows and u can perform the check of attribute values inside the loop.
    Example:
    DCIteratorBinding dcib1 = (DCIteratorBinding) bindings.get("ViewObjectIteratorName");
    DCIteratorBinding dcib2 = (DCIteratorBinding) bindings.get("ViewObjectIteratorName");
    for(Row r1 : dcib1.getAllRowsInRange){
    for(Row r2 : dcib2.getAllRowsInRange){
    regards,
    KR

  • TreeModel - Iterate through child records using row EL

    Hi all,
    Jdev Version: Studio Edition Version 11.1.1.7.0
    I have a search page where I need to display the search results of Header and on one of the columns need to display a concatenated list of children.
    Header is a Task and children are Assignees of the task. I am looking to achieve this by using a normal table bound to a tree binding inside which the 'Assignee' view link is added as a child. So the binding is ready. I attempt to use the af:table using the treeModel which also seems to be working fine.
    Now I am stuck on how to iterate through the assignees for each task using EL - #{row.???}
    Jsff  Code snippet
              <af:table value="#{bindings.Task1.treeModel}" var="row"
                          rows="#{bindings.Task1.rangeSize}"
                          summary="#{ResourcesGenBundle['Header.SearchResults']}"
                          varStatus="tableMetadata"
                          selectionListener="#{backingBeanScope.TaskSearchBean.selectHandler}"
                  width="100%" columnStretching="column:resId1c5" autoHeightRows="15">
                    <af:column id="c3" headerText="Assignees">
                        <af:iterator id="i1" rows="2" var="assigRow"
                                 value="#{row.Task11.collectionModel}">                 
                            <af:outputText value="#{assigRow.UserName}" id="ot2"/>
                            <af:spacer width="10" height="10" id="s2"/>
                        </af:iterator>
                    </af:column>
                </af:table>
    Page Def Snippet
        <tree IterBinding="Task1Iterator" id="Task1">
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskVO"
                          Name="Task10">
            <AttrNames>
              <Item Value="TaskId"/>
              <Item Value="Subject"/>
              <Item Value="Description"/>
              <Item Value="PastDue"/>
            </AttrNames>
            <Accessors>
              <Item Value="TaskUser"/>
            </Accessors>
          </nodeDefinition>
          <nodeDefinition DefName="sample.common.publicModel.components.view.TaskUserVO"
                          Name="Task11">
            <AttrNames>
              <Item Value="ListName"/>
              <Item Value="PersonId"/>
              <Item Value="UserRole"/>
            </AttrNames>
          </nodeDefinition>
        </tree>
    Thanks,
    Srini

    Trying out with
    <af:iterator id="i1" rows="2" var="assigRow"  value="#{row.children}">
    Will keep the thread posted on my progress. Meanwhile, any suggestions welcome .
    Another way I could think of achieving this is to not use a UI iterator and instead get the value for my outputText using a bean method where I could get the present row of the tree and get the children and concatenate the Assignee names and return. But UI iterator should be a better way to do this if possible. So still exploring.

  • Iterate through filtered rows

    I have a table (af:table) with a filterable column. How could I iterate through the rows after the filter was applied?
    Thanks in advance
    jleon
    (JDeveloper 11.1.2.4.0)

    Have you tried to get the iterator in the bean method and iterate over it?
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            //access the name of the iterator the table is bound to. Its "EmployeesVOVIIterator"
            //in this sample
            DCIteratorBinding dciter = (DCIteratorBinding)bindings.get("EmployeesVOVIIterator");
            //access the underlying RowSetIterator
            NavigatableRowIterator rsi = dciter.getNavigatableRowIterator();
            while(rsi.hasNext()) {
                Row row =rsi.next();
                // work with the roe
            }Timo

  • 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.

  • Iterate through RichTable with custom cells

    Hi.
    I create a RichTable by drag and drop a view in DataControls. View is from table xxx and table contains only one column, binding description field in the table.
    This description is shown in an OutputText UI component.
    Then, I add a column with a SelectOneRadio component (to check Yes/No).
    Finally, I add another column with an Input Text to write comments.
    So, when I click one button, I capture the action event and want to process table content. But, how can I iterate through this table?
    How can I get each row, and each cell in its row (each radio, each text)?
    My JDeveloper version is 11.1.1.7.0
    Thanks in advance. Best regards
    EDIT: _________Final solution_________
    Add two transient attributes and iterate the VO object is very easy.
    For the specific issue about radio button, add a switcher and bind the radio group with the transient attribute.

    Hi,
    You could do something like
                   <af:switcher id="s1" defaultFacet="input" facetName="#{row.type eq 0?'radio':'input'"}>
                    <f:facet name="input">
                        <af:inputText id="it2" value="#{row.answer.inputValue"}/>
                    </f:facet>
                    <f:facet name="radio">
                        <af:selectBooleanRadio id="sbr1" value="#[row.answer.inputValue"}/>
                    </f:facet>
                    </af:switcher>
    -Arun

  • Iterate through HashMap ?

    Hello,
    is it possible to iterate through a Java HashMap somehow?
    Or is there any other iterable data structure i could use (I need to get objects from the data structure by using an integer value as key ) ?
    thanks!

    It depends...
    Simple answer: you can use keySet() or values() to get respectively a Set or a Collection, then you iterate on them (using iterator()).
    But you have no guarantee on the order of iteration.
    Now, a data structure using an integer as key is commonly called... an array! Half joking, it works well if these integers are consecutive or of limited range.
    If you need to iterate in increasing key values, use a TreeMap.

  • Iterate through HashMap and .....

    Hi friends,
    I have a HashMap with say following entries..
    (ad_key1 , value1)
    (ad_key2 , value2)
    (ad_key3 , value3)
    (ad_key4 , value4)
    (hk_key1 , value1)
    (hk_key2 , value2)
    (hk_key3 , value3)
    (hk_key4 , value4)
    Now my requirement is that i have to iterate through the hashmap and get all the values for the keys starting with ad_ , and not just that whils storing it in some other place remove that ad_ part and store the remaining. so removing the other part od_... and storing it is fine, i will do that.
    But the problem is how do i iterate through the HashMap in a way that i retreive first key then check if it is starting with ad_ , then retreive second key and check that whether it is starting with ad_ and so on .
    please do help,
    thanks in advance

    import java.util.Iterator;
    import java.util.HashMap;
         public class IteratorExample
              public static void main(String args[])
                   HashMap hashMap = new HashMap(); // Constructs a new empty HashMap
                   hashMap.put( "One", new Integer(1) ); // adding value into HashMap
                   hashMap.put( "Two", new Integer(2) );
                   hashMap.put( "Three", new Integer(3) );
                   System.out.println("Retriving all keys from the HashMap");
                   //     retrive iterator from keySet of the hashmap
                   Iterator iterator = hashMap.keySet().iterator();
                   while( iterator. hasNext() )
                        System.out.println( iterator.next() );
         }

  • Get selected row values from Table view control

    Hi ,
    I am using transaction ME23N, would like to access row values from item table for selected row. I have written a script as in screen shot and its giving me error at java script step two. I want to get the PR number from item table for selected row.
    With Regards
    Vishal Lokapur

    H Vishal,
    Can you please share how you were able to resolve the issue regarding the selected row
    in case of a table control .
    Regards

  • Iterate Through Lists Instead of Document Libraries, Or both

    System Info: SharePoint 2010 Enterprise w DEC 2013 CU. 2 WFEs (load balanced), App Server, SSRS Server, Dedicated CA Server (All running Win 2k8 R2).
    Background:I have a large (5,000 user) application that is completely customized on top of SP2010. I am the admin, and have been on the team for many years. Previously, we had a development team,
    but client has scaled costs back, and now its just me on the technical side. We have a Web app that houses multiple Site Collections, and each site collection has various subsites.
    My Problem: We have increased the LVT to 10k items (system has plenty of HP, although we do see performance degradation). Each subsite in the Site Collection holds data specific to an organization
    wtihin the Line of Business. There are two lists that frequently approach the 10k mark, and we have mitigation steps in place (essentially, we just create a new SubSite for them once they reach 10k). What I need is a single script that will traverse ALL subsites
    and return a count of their lists, perhaps I can work a couple of if statements in there to have specific data written to a SP List (if count is greater than 5000), and other wise everything gets written to the output file.
    I am trying to iterate through all lists and return a count of folders + items ... The script below works just fine, but it goes through Document Libraries only (per the baseType eq tag).
    I've tried changing baseType from DocumentLibrary to GenericList, but I continually get an error.
    I've also removed the where baseType = DocLib clause completely, and this has the desired results (all lists and doclibs are listed), except the 'WebUrl' field in the csv output is blank.
    Any thoughts on how I can make a small tweak to this script to get my desired results?
    Start-SPAssignment -Global
    $OutputFile ="D:\folder\DocCount3.csv"
    $results = @()
    $webApps = Get-SPWebApplication http://WebAppURL
    foreach($webApp in $webApps)
    foreach($siteColl in $webApp.Sites)
    foreach($web in $siteColl.AllWebs)
    $webUrl = $web.url
    $docLibs = $web.Lists | Where-Object {$_.baseType -eq "DocumentLibrary"}
    $docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
    $results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
    $results | Export-Csv -Path $OutputFile -NoTypeInformation
    Stop-SPAssignment –Global

    You guys won't believe this ... But, the script actually works as intended if I change the baseType tag to "GenericList"... I had been getting errors (about 14 of them) through PowerShell and
    assuming the script didn't process, but after looking at the output CSV, it seems that everything worked properly. I think the 14 errors MAY have been corrupted sites (or something?) as it gives me NullValueNotAllowed when trying to "Add-Member" and points
    to $WebUrl as being null.
    Next up -- working on getting this script to write specific objects to a SP list!

  • Java.sql.BatchUpdateException: ORA-12899[ value too large for column.......

    Hi All,
    I am using SOA 11g(11.1.1.3). I am trying to insert data in to a table coming from a file. I have encountered the fallowing error.
    Exception occured when binding was invoked.
    Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception.
    *insert failed. Descriptor name: [UploadStgTbl.XXXXStgTbl].*
    Caused by java.sql.BatchUpdateException: ORA-12899: value too large for column "XXXX"."XXXX_STG_TBL"."XXXXXX_XXXXX_TYPE" (actual: 20, maximum: 15)
    *The invoked JCA adapter raised a resource exception.*
    *Please examine the above error message carefully to determine a resolution.*
    The data type of the column errored out is VARCHAR2(25). I found related issue in metalink, java.sql.BatchUpdateException (ORA-12899) Reported When DB Adapter Reads a Row From a Table it is Polling For Added Rows [ID 1113215.1].
    But the solution seems not applicable in my case...
    Can anyone encountered same issue?? Is this a bug? If it is a bug, do we have patch for this bug??
    Please help me out...
    Thank you all...
    Edited by: 806364 on Dec 18, 2010 12:01 PM

    It didn't work.
    After I changed length of that column of the source datastore (from 15 to 16), ODI created temporary tables (C$ with I$) with larger columns (16 instead of 15) but I got the same error message.
    I'm wondering why I have to extend length of source datastore in the source model if there are no values in the source table with a length greather than 15....
    Any other idea? Thanks !

  • Best way to iterate through multiple variables?

    I need to iterate through three different variables (arrays), and was wondering what the best way to do this would be? I am more familiar with C than I am with LabVIEW at this point, but am getting up to speed on LabVIEW pretty quickly. Normally in C, I would just create three nested loops, but I am wondering if this is the best method in LabVIEW or not. I could use a state machine I think, which would give me some flexibility in re-arranging the order of iteration or adding or subtracting variables easier than working with nested loops I think...anyway, I'm open to suggestions.

    R.Gibson wrote:
    I need to iterate through three different variables (arrays), and was wondering what the best way to do this would be?
    Arrays are not "variables". can you be a bit more specific.
    R.Gibson wrote:
    I could use a state machine I think, which would give me some flexibility in re-arranging the order of iteration or adding or subtracting variables easier than working with nested loops.
     Why does the order matter? Rearranging in what way? If you do autoindexing, it will just iterate over all elements until it runs out of elements.
    ... And again, what do you mean by "variables"?
    It would help if you could show us a VI containing some typical input data in controls (make current value default, save) and explain what kind of output you expect.
    LabVIEW Champion . Do more with less code and in less time .

  • For loop to iterate through temp table in store procedure in pl/sql

    Hi,
    how to create For loop to iterate through the temporary table in the store procedure?

    Neha RK wrote:
    hi,
    its not working , i need to check each record of table and do some task using if else loop inside that for..
    if not possible to loop each row of table using for then how to use while loop.
    please helpWhat's not working? We haven't got psychic powers so we can't see the code you say isn't working.
    Please provide more information like create table statements, insert statements with test data, the code you've tried
    and the output you are expecting from the input data.
    Read {message:id=9360002} and follow the advice there.

  • Iterate through XML find the missing element and prepare report

    Hi',
    I am reading a XML and if the ID is missing in that XML, then I have to make a report which can be send by mail
    by telling that these are the name for which ID is not present.
    I am able to iterate through the records and check if the ID is not present and pick the names for that,
    What I am not getting is how to put these names in a proper format.
    Like if I copy then each time the variable will be overwritten, if I use a append then a full new XML gets created.
    Please tell me how I can make a proper report.
    Thanks
    Yatan
    <Records>
    <Employee>
    <name>Yatan</name>
    <ID></ID>
    <Age>28</Age>
    </Employee>
    <Employee>
    <name>Yagya</name>
    <ID>101</ID>
    <Age>27</Age>
    </Employee><Employee>
    <name>Yugansh</name>
    <ID></ID>
    <Age>24</Age>
    </Employee>
    </Records>

    What about you do a XSLT transformation to get the email content in HTML format... That would avoid you to iterate through your XML...
    The template would be like this:
    <xsl:template match="/">
            <h2>These are the employees without ID</h2>
            <xsl:for-each select="/Records/Employee[ID = '']">
                <xsl:value-of select="name"/>
                <BR/>
            </xsl:for-each>
    </xsl:template>This is just a sample, syntax was not verified, but I think you'll get the idea...
    Please let me know if this was helpful...
    Cheers,
    Vlad

Maybe you are looking for