Help req for loop

Hi All,
I am retriving values from database and then writing it to a file...The code for this is
String query = "SELECT Project_Master.proj_name,Project_Master.proj_desc,Project_Master.proj_location,folder_navigation.nav_name, content_document.cont_name,content_document.cont_type FROM Project_Master INNER JOIN folder_navigation ON Project_master.proj_id=folder_navigation.proj_id INNER JOIN content_document ON content_document.nav_id = folder_navigation.nav_id ";
ResultSet rs = stmt.executeQuery(query);
int maxcols = rs.getMetaData().getColumnCount();
while(rs.next())
System.out.println("proj_name::"+rs.getString("proj_name"));
System.out.println("proj_desc::"+rs.getString("proj_desc"));
System.out.println("proj_location::"+rs.getString("proj_location"));
System.out.println("nav_name::"+rs.getString("nav_name"));
System.out.println("cont_name::"+rs.getString("cont_name"));
for(int i =1;i <=maxcols;i++)
myData.add(new Tags_Define(rs.getString("proj_name"),rs.getString("proj_desc"),rs.getString("proj_location")));
I get output of this as
<name>data1</name>
<desc>data2</desc>
<path>data3</path>
this data is repeated 6 times as there are 6 colomns in my table
If i comment out for loop i get the above data 2 times
But I want data to be retained row wise
What should i do?
Please help
Thanks in advance

First of all, when posting code, click the code button.
Is the for loop meant to be nested in the while or is it supposed to come after it? It is impossible to tell as you did not include the closing brace.
Also this code:
String query = "SELECT Project_Master.proj_name,Project_Master.proj_desc,Project_Master.proj_location,folder_navigation.nav_name, content_document.cont_name,content_document.cont_type FROM Project_Master INNER JOIN folder_navigation ON Project_master.proj_id=folder_navigation.proj_id INNER JOIN content_document ON content_document.nav_id = folder_navigation.nav_id ";is much longer than it needs to be. Are you sure it executes without errors? Why don't you use a table alias instead?
String query = "SELECT PM.proj_name,PM.proj_desc,PM.proj_location,folder_navigation.nav_name, content_document.cont_name,content_document.cont_type
FROM Project_Master PM INNER JOIN folder_navigation ON PM.proj_id=folder_navigation.proj_id INNER JOIN content_document ON content_document.nav_id = folder_navigation.nav_id ";also, you have not specified folder_navigation or content_document in the from clause, I presume these are also tables? Also, what is myData? We do not see it declared anywhere.

Similar Messages

  • Need help w/ for loop, a do loop, and a do-while loop.

    Hello I have been trying to write a program that uses a for, do, and a do-while loop, but I am having trouble. I need the program that will prompt the user to enter two numbers. The first number must be less than the second number. I need to use a "for loop", a "do loop", and a "do-while loop" to display the odd numbers between the first number and the second number. For example, if the user entered 1 and 8, the program would display 3,5,7 three different times (one for each of the loops). Please help if you can. Thanks.

    boolean2009 wrote:
    Thank all of you all for responding.Youre welcome.
    Yes this is my homework, but my major does not even involve java i just have to take the class.Not our problem.
    And yes we are suppose to have all three in one program I do not know why,So you can learn all three types of loops (there is also an enhanced for loop to learn later on).
    but I just do not understand programming nor do i really want to.Once again not our problem.
    If anybody could help it would be much appreciated. thanks.Yes, a lot of people are willing to help you. No, none of them will do it for you. What you need to do is attempt the code and when you get stuck, post your code using the code button, include error messages, indicate which lines in your code genereate those error messages and ask specific questions.

  • HELP! FOR LOOP TO SCROLL THROUGH TABLE AND CREATE DATABASE LINK

    Hi,
    Here's the scenario, not much of a PL programmer, just basic SQL so really need some help people!
    I have 2 tables. 1 contains list of DB's and the other contains rules to follow.
    I need to create a loop that goes through the table containing the DB's and on each row a DB link is created (Only 1 link allowed!)
    Once created, the schema currently logged in with also has an account on the linked DB in order to run scripts- The scripts are stored centrally hence the requirement for the link to the target DB.
    There are numerous scripts that need to be executed and can all be called from 1 script, once executed the loop exists and the database link needs to be dropped.
    Once dropped, the first loop continues, creating a DB link for the next DB listed in the table (and all the scripts are fired again)
    This continues against all the DB's listed in the table.

    Hi BlueShadow,
    Thanks again for the response, you've hit the nail on the head. SQL scripts on a unix server, a loop goes through a table 1 at a time. Each row gets a link created and then all the scripts stored on the server are executed against the db linked to. So I'm assuming this is a loop within a loop.
    1 loop to go through the table to create the link and then another loop within once connected to execute all the scripts against the connected DB. Once the scripts are run, the loop exits and moves onto the next server and so on until all the servers have the scripts are run.
    It's PL/SQL scripts we're after and not shell scripts as this would free us from the OS constraints.
    We have to drop the links due to security. Any idea on o

  • Help req for check customer table maintenance with XD02 if not throw error

    hello ABAP GURUS,
    check customer of the table maintenance with XD02 if not throw error i have given the codition for passing the values in the table but before that it has to check whether the customer i am passing in to the table is a customer from xd02.Here whatever no i am passing it is accepting it should not happen, but when i give the customer which is not a customer it should not accept but it has to throw the message as 'customer does not exist.Its urgent please help me
    TYPES: BEGIN OF TY_KNVI,
    KUNNR TYPE KUNNR,
    TATYP TYPE TATYP,
    TAXKD TYPE TAKLD,
    END OF TY_KNVI.
    DATA : VALIDFROM TYPE GUEBG,
    VALIDTO TYPE GUEEN.
    DATA : IT_KNVI TYPE STANDARD TABLE OF TY_KNVI,
    WA_KNVI TYPE TY_KNVI OCCURS 0 WITH HEADER LINE.
    DATA : V_NAME TYPE SYUNAME.
    SELECT KUNNR
    TATYP
    TAXKD
    FROM KNVI
    INTO TABLE WA_KNVI
    WHERE KUNNR = YYV_CFORM-KUNNR
    AND TATYP = 'ZCST'
    AND TAXKD = '1'.
    V_NAME = SY-UNAME.
    YYV_CFORM-ENTEREDBY = V_NAME.
    IF SY-SUBRC NE 0.
    MESSAGE E000(E4) WITH 'Please change the tax classification of ZCST as' '1' ', in Sales Area Data'.
    ENDIF.
    I have used the following code to enter the data into the table maintenance it is working fine and throwing the error when the tax type is not the one which i have given in the select statements but the problem is when i have given the customer no which is not there in the XD02 tcode, it is accepting and showing the error message as MESSAGE E000(E4) WITH 'Please change the tax classification of ZCST as' '1' ', in Sales Area Data'. now i have to check the customer no from XD02 and if it is existing in that tcode it should allow to save in the table maintenance otherwise throw a message as the 'Customer no does not exist, this I am unable to write so how can i check please help me .
    thankx in advance.
    Edited by: soni khadary on Apr 22, 2008 7:55 AM

    Hi Kelly,
    I guess <wa_tab>-handle_style is of type lvc_t_styl therefore you can do the following:
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    "I assume you know your non-key fields' names so you can use subrotuine to perform update on each of them
    ls_edit-fieldname =  'First field name' .
    PERFORM update ls_edit.
    ls_edit-fieldname =  'Second field name'.
    PERFORM update ls_edit.
    ls_edit-fieldname = 'Third field name'.
    PERFORM update ls_edit
    FORM update USING fs_edit type lvc_s_styl.
    field-symbols: <style_tab> type lvc_t_styl,
                         <style_wa> type lvc_s_styl.
    LOOP AT <tab> ASSIGNING <wa_tab>.
       if e_row = sy-tabix .
         "get you style table
         assign component 'HANDLE_STYLE' of structure <wa_tab> to <style_tab>.
         "as <style_tab> is typed fully you can read the row you are interested in
         read table <style_tab> assigning <style_wa> with key fieldname = fs_edit-fieldname
         if sy-subrc = 0.
           "update this entry
            <style_wa> = fs_edit.
    *        modify table <style_tab> from <style_wa>. 
         endif.
       endif.
    endloop.
    endform.
    Note!
    Though, this should work, the use of RTTI as Uwe suggested would be best practise approach as far as dynamic programming is concerned. Anyhow it is still up to you which one you pick.
    Regards
    Marcin
    I noticed now that this line is not necessary
    modify table <style_tab> from <style_wa>. 
    as we simply are working with field symbols, so changes made to <style_wa> are already visible in that table <style_tab>.
    Edited by: Marcin Pciak on Mar 15, 2009 12:44 PM

  • Help with for loop and remove-item command

    Hi all here is the code so far
    $a = Get-Content C:\Users\cody-horton\Desktop\test.txt
    for($i=0;$i -lt $a.Length;$i++){
    #$temp = [int32]::Parse($a[$i])
    Remove-Item '\\ceit2551202x0'$a[$i]'\C$\Program Files\MATLAB\R2013a\*' -Force
    I have a text file with a few number in it that i want to get. They are in the array $a but I'm getting an error that says a positional parameter cannot be found that accepts argument '53' (it does this for all the numbers in the array.) I know in java you
    could have something like this   string + int + string. 
    I'm not sure what to do I also tried to parse it with no luck. Thanks any help is appreciated.

    Your issue is with the path for Remove-Item, it is not complete so try this
    Remove-Item "\\ceit2551202x0$($a[$i])\C$\Program Files\MATLAB\R2013a\*" -Force
    I am unable to test, so I would add the -WhatIf switch to make sure it outputs what you expect
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

  • Help req for screen exit in migo

    Hi guys,
                 I am using badi MB_MIGO_BADi to design an header screen i am facing following issues
    1) It should be active for a particular plant. Now which badi/exit shld be use to export the value of plant
    to badi to make it visible or invisible. IF its invisible does it also make it inactive??
    2) to save the data from the screen into an z table. i put a break point in exit MB_CF001 but its not executing when
    clicked on save while creating GRN against a PO.

    Hi,
    rearding the capturing of transit loss, I guess you can use the field 'Qty in Delivery note" to capture the Qty claimed to be delivered and capture the actual qty in the qty in Unit of entry field.
    The difference would the transit lodd.
    You can build reports on these.
    Hope this helps.

  • Help Req for creating tool tip for value

    Hi ABAPers,
    I have created the search help for material.
    In search help output screen ,
                           I have the column contain a long text with the output lenght as 40 char that is displayed and once i put the mouse on it the entire  long text  should apears.
    Kindly help.
    Thanks & Regards
    Sachin Yadav

    If it is a input text field... i think not possible.
    This is only possible for buttons on toolbar (as far as i know)

  • Help Req for fresher

    I am new in this area. Pls send me some documents and reading material at [email protected] Points awarded.
    Thanks
    Murali

    Hi Murali,
    Maybe the SAP Online Documentation can help you on this.
    http://help.sap.com
    There you will find all the necessary informations on PLM issues for your used release.
    Best regards,
    Chrisoph

  • Help req. for IS-T

    Hi all,
             My new assignment is come under IS-T (Telecommunication).  I am working as a MM consultant. Can any body give me some idea about IS-T customization path or Tcode or useful link. This there any special setting required for IS-T.
          Thanks in advance ( if you have any useful document then send me on sk_deo at the rate lycos dot com )
    regards
    Sanjay

    http://help.sap.com/saphelp_telecom472/helpdata/en/5F/B82C368CAE9167E10000009B38F839/frameset.htm
    Master Data Details:       
    Business Partner  :: BP
    Contract Account  ::  CAA1,2,3.
    Regards,
    Shiva

  • BDC help req for MM02??

    hi
    I made a BDC pgm for MM02,to update the Purchasing Group filed for a matnr,based on Plant.
    But i am facing an prob that,when in a Matnr views,my curcur is coming to  Purchsaing View ,it update the EKGRP filed,but  when it directly comes to MRP 1,its given an error,that MARC-EKGRP not exits.
    Moreover I had done only recording for Purchaing View,not for MRP 1 view,but not able to understand why its going there in MRP 1 view,some time for some materials.
    Can any one tell me,how to rectify this prob?
    Regds.

    Hi,
    This problem occurs because,
    Different materials have different types,
    so this view will not be same for all,
    so if you have done recording for 4th tab ,than for next material at 4th tab some other thing will be there,
    to rectify this problem,
    do the recording for basic data 1 (it will be present for very material ) and then goto the required tab,
    i hope  it fits to your requirement,
    Regards,
    Talwinder

  • Help Req for Rounding Rule,

    Hi All,
    Can some one tell me what r the steps to be created in rounding rule of Absence Quota.
    Regards,
    Vinod.

    Define Rules for Rounding Counted Absences
    In this step, you set rounding rules for absence and attendance counting.
    If you specify an hours or day multiplier for counting attendances and absences, the values determined can have several places behind the decimal point. It is difficult to use these values for quota deduction and payroll. In this step, therefore, you set rules for rounding the values.
    You use concrete numbers for the rounding rules and can specify whether you want:
    Only values within the specified interval to be rounded or the interval to be rolled
    The specified upper and lower limits to be included in the calculation
    You can specify several subrules for a rounding rule and number them sequentially. The system runs through the subrules in sequential order until it finds one that applies.
    Example
    For absences, you use a counting rule that is counted using an hours multiplier of 80%. You want whole numbers (full hours) to be determined in counting.
    Define a rounding rule
    With a lower limit of 0.5 (inclusive)
    With an upper limit of 1.5 (not inclusive)
    With a target value of 1
    You want the rule to be rolled, that is, to apply also to the following intervals:
    1.5 - 2.4 (rounded to 2)
    2.5 - 3.4 (rounded to 3)
    and so on.
    Standard settings
    The standard system contains sample rounding rules.
    Activities
    1. Define a rounding rule.
    2. If you want to specify several subrules, number them sequentially.
    3. Enter the upper and lower limit of the rounding interval.
    If you select the Incl. field, the value of the specified upper or lower limit is included in the rounding (greater than/equal to or less than/equal to).
    4. Enter the target value to which you want the value to be rounded.
    5. If you want the rounding rule to be rolled, select the Roll. field.
    Further notes
    You can also use the rounding rules you define here for other purposes, for example, to round quota entitlements that have been generated automatically.

  • Help with Mathscipt and for loop

    I have a code in Mathscript/matlab and I need to output the array out. One option is my first code,the other option is using a for loop, but I am only getting the last ouput out. I need to get the whole output out.
    Any help.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Help with Mathscript_for loop.vi ‏115 KB
    Help with Mathscript_for loop2.vi ‏84 KB

    Here's how it should look like.
    Message Edited by altenbach on 10-30-2008 05:12 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    MathscriptInFOR.png ‏15 KB

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Need help in creating for loop

    Hi,
    I want to create two different Xquery transformation by checking attribute value in the input xml.
    <n:DIAMessage xsi:schemaLocation="http://pearson.com/DIA C:/shashi/rewrite/DIA/DIA_Schemas/DIA_new.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n="http://pearson.com/DIA">
    <n:Customer>
    <n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
    </n:hasAccountRelation>
    </n:Account>
    <n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
    <n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
    </n:hasAccountRelation>
    </n:Account>
    <n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:IDType>GENDER</n:IDType>
    <n:IDTypeName>GENDER</n:IDTypeName>
    <n:IDValue>M</n:IDValue>
    </n:hasIdentifier>
    </n:Person>
    <n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
    <n:IDType>GENDER</n:IDType>
    <n:IDTypeName>GENDER</n:IDTypeName>
    <n:IDValue>M</n:IDValue>
    </n:hasIdentifier>
    </n:Person>
    </n:Customer>
    </n:DIAMessage>
    From the above Message i need to create two transformation by checking
    if (DIAMessage/Customer/Account/@sourceClassName="Account")
    then call {
    Xquery1
    if(DIAMessage/Customer/Person/@sourceClassName="Person")
    then call{
    Xquery2
    Constraint here is Account and Person block occurence will be many times.As they are in same hierarchy how to create a for loop concept here?
    Please anyone can help me on this?

    Hi,
    Create a numeric variable to act as While loop counter and assign value of 1. Create a boolean variable to act as a flag to exit loop and assign value of true.
    Create a while object with a condition that while flag variable is true loop.
    Then you can create a switch with a case for each of your scenarios, referencing the xth record (defined by loop counter variable) in xml using ora:getElement
    When the count of required elements in input xml is less than your loop variable, assign the variable to exit loop as false...otherwise increment counter by one to loop to next record.
    Hope this helps.

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for