How to make for loop pass only once in a next() method

Good Day!
Can anyone help me or suggest any idea to resolve my problem with the below code, wherein it will only pass the for loop only once. I already tried inserting the for loop in side the if (sqlset4.isFirst()) condition but the problem is it only retrieved the first row of the resultset.
Cheers!
               Statement sOutput = consrc.createStatement();
                        ResultSet sqlset4 = sOutput.executeQuery(xquery);
                        ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                        int numberOfColumns = rsMetaData.getColumnCount();
                        String writefld = "";
                        while (sqlset4.next()) {
                             writefld = "";
                             for (int i = 1; i <= numberOfColumns; i++) {
                                 if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                     writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                            writefld = writefld.substring(0, writefld.length() - 1) + ")";
                            output.write("\r\n");
                            output.write(writefld);
                        output.close();I am using Netbean IDE 6.8
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi

Hi everyone!
What I actually trying to do is that I have a multiple tables and from these tables I'm going to write each of it into a flatfile that is a pipe delimeted that is why I have to make a loop to know how many fields I am going to write. The code that was attached are actually working, my only concern is that it will take a longer time of processing cause every record of a table it will pass to the for loop(checking how many column) wherein number of column/ were already known on the first loop.
Hi kajbj,
I think what your trying to explain is almost the same with below code which i had already tried. The problem with this is that the every loop of the outer loop data retrieve is only the data of the first record.
               Statement sOutput = consrc.createStatement();
                        ResultSet sqlset4 = sOutput.executeQuery(xquery);
                        ResultSetMetaData rsMetaData = sqlset4.getMetaData();
                        int numberOfColumns = rsMetaData.getColumnCount();
                        String writefld = "";
                        while (sqlset4.next()) {
                             writefld = "";
                             if (sqlset4.isFirst()) {
                                for (int i = 1; i <= numberOfColumns; i++) {
                                    if (xxformatid.equals("1") || xxformatid.equals("3")) {
                                        writefld = writefld + "sqlset4.getString(" + i + ").trim()" + "|";
                            writefld = writefld.substring(0, writefld.length() - 1) ;
                            output.write("\r\n");
                            output.write(writefld);
                        output.close();

Similar Messages

  • How to make a loop run for specific period of time ?

    hello !
    i'm new to labview and could'nt found how to make a loop run for 2 sec for example, and then to exit.
    Solved!
    Go to Solution.

    Hi Hookso,
    You can do it using the different loops like While loop and For Loop. Roderic has already stated how to do it using a for loop. I have illustrated in the attached vi how to do it using a while loop and Elapsed Time function. Take a look.
    Regards,
    Nitzz
    (Give kudos to good Answers and Mark it as a Solution if your problem is Solved) 
    Attachments:
    Untitled 2.vi ‏36 KB

  • Pl.ignore pevious post--make some fields appear only once....

    hi,
    my report looks like this:
    batch no:-date:----name:--amount:---so many fields:
    1---------01/01/03---abc----$50------.....
    ----------01/01/03---bcd----$20------.....
    ----------01/02/03---hgi----$30------.....
    ----------BATCH TOTAl:-----$100
    =====================================================
    question:-> is there any way that I can make date field appear only once if the date is same?
    Thanks,
    prasad.

    That is the trick of my question.
    I wanted the total value to be grouped by Batch Number and NOT by date and at the same time date should not appear more than once.
    I am not able to convince my client that it is not possible in Oracle to TOTAL BY BATCH NUMBER and GROUP BY DATE.
    Someone has created this report in some other report writing tool (I think MS-ACCESS), and they want the same report in Oralce now at any cost.
    Can I achieve this by writing a trigger? If yes, is there any link or help available?
    Thanks for the reply.
    Regards,
    Prasad.

  • How to get current loop pass for LOGICAL DATABASE

    HI,
    can anyone tell me how to find the current loop pass in case of logical db.
    As i have to put some condition when cursor goes to GET statement 2nd time..??
    Mrunal

    U need to explicitly handle this in the program.
    START-OF-SELECTION.
    DATA  V_I TYPE I.
    Get Event starts
    GET PERAS.
    V_I = V_I + 1.
    IF v_i = 2.
    *write the condition ...
    ENDIF.
    END-OF-SELECTION.

  • HOW TO MAKE FIELDS AS READ ONLY IN TABLE MAINTAINANCE

    HI ABAPers,
    HOW TO MAKE SOME FIELDS AS DISPLAY MODE.
    FOR SUPPOSE, THERE ARE 5 FIELDS in SM30.
    AMONG THEM 1 FIELD SHUD BE USED FOR EDITING AND THE OTHER 4 FIELDS SHUD ONLY BE USED FOR DISPLAY PURPOSE
    WHEN EVER I ENTER A VALUE IN THAT 1 PARTICULAR FIELD THEN THE DATA OF THE REMAINING 4 FIELDS SHUD BE DISPLAYED IN THE SAME SCREEN ITSELF.
    HOW CAN IT BE POSSIBLE...
    PLZ HELP.
    THNX IN ADV,
    SP.

    Hello SP,
    You can create a maintenance view for the table & here you can define the maintenance attribute for individual fields.
    For the fields you want to be READ-ONLY pass 'R' to those fields. (It is the 4th column from the left, the one to the immediate left of the Key column).
    Don't change the TMG function group directly. If you regenerate the TMG the changes would be overwritten !
    You can use the Event '01' to fulfill your requirement:
    *&      Form  f_event_01
    *       text
    FORM f_event_01.
      DATA: v_indx TYPE sy-index,
            v_land1 TYPE land1,
            v_name1 TYPE name1.
      FIELD-SYMBOLS: <vendor> TYPE lifnr,
                     <val> TYPE ANY.
      BREAK-POINT.
      "TOTAL contains all data which are read, changed and created in TMG
      LOOP AT total.
        IF <action> = neuer_eintrag " New Entry.
        OR <action> = aendern "Changed entry
        OR <action> = original. "Same as DB
          READ TABLE extract WITH KEY <vim_xtotal_key>.
          IF sy-subrc = 0.
            v_indx = sy-tabix.
          ELSE.
            CLEAR v_indx.
          ENDIF.
          ASSIGN COMPONENT 'LIFNR' OF STRUCTURE total TO <vendor>.
          CHECK sy-subrc = 0.
    *     select data from the LFA1 based on LIFNR
          SELECT SINGLE name1 land1 FROM lfa1
            INTO (v_name1,v_land1)
            WHERE lifnr = <vendor>.
          CHECK sy-subrc = 0.
    *     Populate the hidden fields NAME1 & LAND1
          ASSIGN COMPONENT 'NAME1' OF STRUCTURE total TO <val>.
          CHECK sy-subrc = 0.
          <val> = v_name1.
          ASSIGN COMPONENT 'LAND1' OF STRUCTURE total TO <val>.
          CHECK sy-subrc = 0.
          <val> = v_land1.
          MODIFY total.
          CHECK v_indx GT 0.
          extract = total. "Pass the changes in TOTAL to EXTRACT
          MODIFY extract INDEX v_indx.
        ENDIF.
      ENDLOOP.
      sy-subrc = 0.
    ENDFORM.                                                    "f_event_01
    BR,
    Suhas
    Edited by: Suhas Saha on Aug 16, 2010 11:58 AM

  • Transformation Routine for checking condition only once

    Hello,
    I would like to perform he calculations based on certain criteria which goes like this...
          LOOP AT ITab WHERE EMPno  = ITAB Empno AND
                            ATYPE = ITAB-stype .
            IF ITAB-LTYP = '1000'.
              CHECK ITab-ABEGIN GE YR_BEGDT AND ITab-ABEGIN LE YR_ENDDT.
              CHECK FLAG_ST <> 1.
              ITAB-PENDING_ST = ITAB-PENDING_ST + ( ( ITab-BAL / 825 ) * 100 ).
            ELSEIF ITAB-STPE = '2000'.
              CHECK FLAG_SL <> 1.
              ITAB-PENDING_SL = ITAB-PENDING_ST + ( ( ITab-BAL  / 825 ) * 100 ).
              ENDLOOP.
          IF ITAB-stype  = '1000'.
            FLAG_ST = 1.
          ENDIF.
          IF ITAB-stype  = '2000'.
            FLAG_SL = 1.
          ENDIF.
          MODIFY ITAB.
    How to implement this logic in Transformation roles ... as this flag checks only once.... to perform the calculation.
    Thanks
        ENDLOOP.

    Hi there,
    You must be aware of start and end routine in a transformation.
    Assumin that you would like to modify the code before sending it to individual( field wise transormation) transformation , you can write your code in start routine tab of the transformations.
    Code written in Start routine in a transformation can manipulate the data data package wise..
    say for eg if u need to fill the values in indivual routine  then u can save all  the values in an internal table ( say for eg ur itab) in the start routine and this data is available for u in the transformation routines.. so anything written in start rotuine shall work as global modification for the transformation routines.
    Similarly code written in end rotuine shall work for chunk of data which is modified individually in transformation routine.
    you ca go thr this link for more clarification
    http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3417700)ID2067718350DB10090875593766856688End?rid=/library/uuid/609eea32-455e-2c10-c08a-c23adf8c934e&overridelayout=true
    http://help.sap.com/saphelp_nw04/helpdata/en/4f/a9ea964a86b04dbe4df20af6e598cf/frameset.htm
    Regards,
    kk

  • How to make a PDF viewable only through an URL or a link?

    Hi
    I'm a newbie to Adobe Lifecycle ES. My ultimate aim to use this suite is to make my pdf viewable only through an URL or a weblink. The system must not allow the user to view the PDF without the particular URL. Is it possible to acheive this through Adobe Lifecycle ES? Please do reply as i'm in an urgency to finish my task.
    Thakns in advance

    If you are trying to control access to the actual URL where the Rights Managed PDF you would need to set up a way to authenticate users to allow them access ot the URL.  This would be done on the web\app server, not using Rights Management ES.
    You would use Rights Management ES to apply a policy to the PDF itself.  A policy controls who can view (open) the document, and once the user authenticates to the RM server to open the document, RM controls the permissions that that user has for the document (i.e. can the PDF be printed, can content be copied etc...)  RM cannot be used to control who can download a PDF form a URL.  Policies can also control if the user must be online and connected to the RM server to open the PDF, or you can allow "Offline" access for a set period of time where the user does not need a connection to view the PDF, however the user still needs to be authenticated to view the document offline.
    Regards
    Steve

  • How to skip for loop execution

    Hi all,
    How to skip execution of for loop , if one particular condition is satisfied within that loop .
    I know that we can use exit within for loop to come out of for loop, please let me know if there is any other approach .
    Thanks,
    P Prakash

    BluShadow wrote:
    11g (new feature) - it is called the CONTINUE statement.Blergh! it's horrible. May as well use a GOTO.... :{noformat}/{noformat}Hehe.. Yeah - it essentially creates another exit point in the loop, except that it falls into the top of the loop and not out of the bottom.
    So in that respect, the EXIT statement ain't much better. {noformat} ;-) {noformat}
    Personally I don't think it that bad - could be useful for very tight loops where you want to cut down machine code to the absolute minimum. But then why would one ever write such a loop in PL/SQL?
    Reserving judgement on this one for the time being. I very very seldom have used a continue or skip instruction in programming... As far as I recall - only in bash shell scripts.
    So yeah, I would like to see the code and justification for that code using the CONTINUE statement. There always could be The Real And Seldom Seen Bigfoot-like Exception that justifies using that statement... {noformat} :-) {noformat}

  • How to make a loop of redirecting?

    I'm writing a servlet that can redirect through sites after an amount of time. For example: yahoo.com then google.com then dell.com... But my knowledge is limited to using setHeader("Refresh", "Time; URL") so it can only redirect for 1 time.
    Can any one give me a help?

    Hi Hookso,
    You can do it using the different loops like While loop and For Loop. Roderic has already stated how to do it using a for loop. I have illustrated in the attached vi how to do it using a while loop and Elapsed Time function. Take a look.
    Regards,
    Nitzz
    (Give kudos to good Answers and Mark it as a Solution if your problem is Solved) 
    Attachments:
    Untitled 2.vi ‏36 KB

  • How to make report that contains only summaries?

    How to make a report in Designer/2000 that shows only summary fields? For example something like:
    select count(*) from emp;
    null

    How to make a report in Designer/2000 that shows only summary fields? For example something like:
    select count(*) from emp;
    null

  • How to make a page read only

    Hi all,
    Can anyone please help me out on the following issue.
    How to make a total page read only, so that he/she can not make any changes. I want the total page read only.
    Do we have any functions to do that?
    I need to do through peoplecode only because i have to check a condition.
    Please help me.
    Thank you,
    Bye.

    Without customizing, this may be accomplished via Permission List Security.
    Go to PeopleTools - Security - Permission List
    Select the desired Permission List. Click on the Pages tab.
    Find the menu and click on "Edit Components" hyperlink.
    Find the Component on the List and click on the "Edit Pages" hyperlink.
    Click on the Display Only check box for each page in the component you wish Display Only.
    If that does not sufice, you may use PeopleCode to set the Field DisplayOnly property to true for those editable fields that you wish not to be.
    HTH
    Steven E. Davies

  • How to create for loop USING a while loop

    Hi, I would like make a for loop inside of a while loop because I want to control the i count of the loop, and overall, more control over the loop. From what I understand, labVIEW's for loop doesn't let me change where the i count starts. It always start at i=0, and what I want to do is be able to jump to specific loop iterations and then continue from there.
    Thank you.

    That is not the same as the earlier examples.
    If you want 10 counts and start at 0, then the stop terminal will stop after 10 times.  Just like you get when you wire 10 into the N terminal and don't have a conditional loop.
    If your start value is larger, let's say 9, then your loop will only run 1 time because i=0 on first iteration + 1+ 9 (start value).  0 + 1 +9 = 10.
    If your start value is larger than 10, then it will run 10 times again because on the intial iteration the result of your comparison is already greater than 10 and won't stop, and will never be equal on later iterations.
    So your example does not even give consistent results depending on the value you use as the start value.
    (Just to note, my earlier examples may not all be identical results as I didn't try to verify all the stop conditions nor the array that is output by the ramp function.  I could be off by one iteration here or there.  But they should be good enough to point out distinctive ways to accomplish what the OP asked for.)

  • How to Prompt for User/Pass Running Shell Script Remotely through ARD

    So I finally got my Active Directory Script working! However, I realized that I'm not the only one going to be running this script and to have my user name and password in the script itself is beyond foolish. While I know it's possible just to have whoever's running the script to manually add their username and password, I'd prefer to have prompts to make things easier for the rest of my team.
    Here's my current script. I've tested it on the machine I'm connecting to Active Directory and it works fine if you run it on the machine itself in terminal. However, I'm going to be doing this on about 150 machines and the whole point of the script is to do it remotely.
    #! /bin/bash
    MACNAME=$(scutil --get ComputerName)
    read -p "User Name: " USER
    read -p "Password for $USER: " PASS
    dsconfigad -add "CORP.DOMAIN.NET" \
    -username $USER \
    -password $PASS \
    -computer $MACNAME \
    -mobile disable \
    -mobileconfirm disable \
    -localhome enable \
    -useuncpath enable \
    -shell /bin/bash \
    -ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net \
    -force \
    -localpassword "PASSWORD" \
    -groups "GROUPS"
    When I run the UNIX script through ARD to a machine, I get no prompts for USER or PASS. In fact, it gives me the following error "dsconfigad: Authentication server encountered an error while attempting the requested operation. (5202)" So it's not asking for a user name and password.
    Is there any way to make a shell script prompt you for a User Name and Password when you're sending commands remotely through ARD? Or is there another way to do this?
    Any suggestions would be greatly appreciated.
    -rks

    Best solution is to create an account that is exclusive to binding machines.  By doing this, you can embed the user name and password in the script.  Heck, you can post it on your website.  If the account is configured properly, it will only be able to create machine records in a defined container.  If you are mixing Macs and PCs in your AD domain, I also recommend creating an isolated container for your Mac records.  Now, the account has even less access rights as you can make it so it only has rights to the Mac container.
    Otherwise, ARD does not prompt.  You can play around with an expect script but the reality is that you are still embedding the credentials in the script so it really does not achieve what you want.  ARD is not an interactive shell scripting tool.  It is more a fire and forget.
    Reid
    Apple Consultants Network
    Apple Professional Services
    Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

  • Need to populate value for a KF only once for a combination of characterist

    Hello All,
    We had a requirement for a report. wherein we need to consolidate the data of the 0FI_GL_4 datasource and a custom table.
    both these sources have only 4 fields in common i.e Fiscal Year/Period; Company Code and Pool
    in the custom table, for each fiscal yr/period & Pool combination, there is a unique Plan value available.
    To consolidate the data, I wrote a routine in the transformation to extract data from the custom table based n the combination of Fisc yr Period, Comp Code & Pool.
    However, since 0FI_GL_4 has more than 1 entry for the above mentioned combination  that is GL_accounts, document number, etc; during extraction, my plan value is being extracted multiple times to the cube and hence for a fiscal yr/period, cube shows a summation value.
    I want the plan value to be picked only once.. please advice

    Hi Sneha,
    As I understand in your infocube along with the primary key of custom table one more field exists e.g. Document number and due to which the value is getting repeated over multiple lines.
    Though all these records are valid but when you are running report on this cube without document number all the plan values are getting aggregated, again this behaviour is also correct.
    For your reporting purpost I feel that you need to extract data from the custom table in other data target and then do the reporting on that, wherein the plan value will not be repeated.
    Regards,
    Durgesh.

  • How to use for loops with Multiple Initializers and Incrementers

    I found that my for loop is printing out wrong, because I am using two for loops. I have searched but all I can find out is you can't use multiple inializers and increments, does anyone know how to get around this? How would I use an array for this?
    Thanks very much for your help.
    import java.util.Random;
    import java.util.Arrays;
    /** Generate numnodes value for random integers in the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range 0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    }

    Sorry that code works, but I want to use both my x and y coordinates to get a random number from 0 to 499 in both of them, then I want to do some comparisons of the values, then return it to another function. As it stands now, I get the wrong results when I run it, as you can see at the bottom.
    Thanks very much for your help. I have been stumped all mornign on this and have looked everywhere trying to find an example. I don't won't to use math random. I am on a tight deadline to finish and at the rate I am going, I will not complete it.
    /** Generate numnodes value for random integers in
    the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range
    0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for
    the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    private static void log(String aMessage){
    System.out.println(aMessage);
    Output:
    --------------------Configuration:
    <Default>--------------------
    Generating 6 random integers in range 0..499.
    Generated : 98 254
    Generated : 98 347
    Generated : 98 359
    Generated : 98 25
    Generated : 98 277
    Generated : 98 148
    Generated : 416 401
    Generated : 416 165
    Generated : 416 354
    Generated : 416 169
    Generated : 416 144
    Generated : 416 354
    Generated : 295 158
    Generated : 295 138
    Generated : 295 349
    Generated : 295 324
    Generated : 295 18
    Generated : 295 193
    Generated : 197 451
    Generated : 197 416
    Generated : 197 480
    Generated : 197 33
    Generated : 197 490
    Generated : 197 494
    Generated : 324 412
    Generated : 324 490
    Generated : 324 213
    Generated : 324 386
    Generated : 324 467
    Generated : 324 163
    Generated : 379 180
    Generated : 379 446
    Generated : 379 314
    Generated : 379 52
    Generated : 379 113
    Generated : 379 271
    Done.
    Process completed.

Maybe you are looking for

  • Embed Video in Word Acrobat 9

    Okay, I've lloked at seom of the forum post, but could not find an answer.  Here's my dilemna.  We have a full license of Acrobat 9 Pro.  When using Word, I try to embed a video via the Embed Video option in the Acrobat tab.  However, that option is

  • Accented characters on windows the mac way

    It took me a while to write the accented characters in mac. For instance, option-E for acute, then vowel: like, opt-e then a= á Now, I need windows for a series of reasons. However, I cannot make windows behave like this. I want windows to show the e

  • Jpegs appear transparent when imported

    Working in Windows 7 on CS5 Extended. When opening jpegs either through Bridge or directly through Photoshop, the image appears like a transparent checkered background. In the layers window the thumbnail shows the proper image. This is when things ge

  • Album Display Not grouping tracks correctly

    Hello, I'm having a strange behavior in iTunes while in 'List View'. When in list view, when I select an album, I have the first track on it's own with the artwork displayed with track information then there's a separator followed by the artwork agai

  • Java.lang.UnsatisfiedLinkError: Help Sought.

    Hi, I have a DLL and i know the method signatures, which is: USB_STATUS USB_Initialize(short nWidth, short nHeight, HWND hWnd); USB_STATUS is of int type or probably it returns int type. It may be a struct also. I am not sure how it is defined as i j