Making a connector in while loop

I want to make a subvi with a while loop.
For example, there is a indicator inside while or for loop as my attachment.
Actually, the indicator will be used as a progress bar which need to be updated in realtime in main vi.
In my first thinking, the subvi is used in a simple event-driven structure(main vi) to start by a button (for user interface).
But I realized this method is not suitable for updating the indicator in realtime after pushing the start button.
How to make a subvi for the indicator and use it?
That is, how to extract the value inside while loop to outside the loop in realtime?.
Lee
메시지가 08-12-2007 07:30 PM에 labmaster에 의해 편집되었음
Attachments:
aaa.jpg ‏13 KB

trivial example attached, two vis in labview 8.2.1
Paul <--Always Learning!!!
sense and simplicity.
Browse my sample VIs?
Attachments:
mainVi.vi ‏7 KB
subviThatUpdatesMainProgess.vi ‏10 KB

Similar Messages

  • Making a Menu in the command console w/ a While loop

    Hello,
    I need to design a menu in the command console that allows the user to enter a choice, and after doing so will bring the user back to the original menu of options.
    Now I already have set up the menu and I got it working so the user can enter their choice however my questions is, I know I need to use a while loop, but how would I go about doing so in order to have it set up that after a choice is entered it displays the results and then goes back up to the original menu.
    I know these new versions of Java do not have a simple GOTO command I can use so I was told a while loop is the way to do it. I know how to set up while loops, I guess what I am asking is what my terminating/repeating condition should be and how to get the program to go back up to the top of the loop thus displaying the menu. Is there any way to maybe use a return false/true and have the loop keep going through only if true? Thanks in advance.

    while( condition )
         //Display the menu here
         choice = //enter choice
         switch( choice )
               case value1 : condition = someMethod1();
                                        break;
               case value2 : condition = someMethod2();
                                        break;
               default : // Do something
                                 break;
    }

  • Making a while loop stop

    I'm trying to write to a file by using a while loop. I read from the keyboard and then enter the while loop. I print to the file and then I read from the keyboard again. My problem is when I want to exit the loop by entering nothing I can't. The loop becomes infinite. Please help!!! Here is my code!!
    inputline = keyboard.readLine();//read the keyboard
    while ( inputline != null ){
    DiskOut.println( inputline );
    DiskOut.flush();
    inputline = keyboard.readLine();//read the keyboard again
    }//end while

    At a guess, it's not returning null when you hit return, but rather the return character. Try something like
    if (inputline == "" || inputline =="\n" || inputline == "\r" || inputline == null) {break;}If that works, you can take out bits to see what it is returning.

  • Making array while looping another array

    hi all,
    i have an array of int values.
    i need to make a list of another values while looping around the int values.
    but the values that are added to the list are objects
    can any one help me with the sample code in getting the list
    any ideas?
    regards and thanks in advance

    Double-posted
    http://forum.java.sun.com/thread.jspa?threadID=648140

  • How to use while loops to implement a simple climate control.

    Hi,
    I am currently a 4’th year computer systems engineering student in South Africa doing a primitive climate control project in LabVIEW 8.0. Although my knowledge and skill level of LabVIEW is far from that of an expert, I really enjoy working with it. The project consists of a motor driving some fan blades, a resistor heater and an analog temperature sensor. The basic functionality entails that a user specifies a desired temperature and then the program will heat if the current temperature is lower than desired or cool if the current temperature is above the desired temperature.
    What I want to add is an acceptable temperature difference so that the fan and heater do not switch constantly as the threshold temperature is reached. Rather leave the current temperature to linger between the maximum (current + acceptable difference) or minimum (current – acceptable difference) allowed temperature before heating or cooling it to the desired temperature once again.
    I have attached 2 VI’s:
    Final Assignment: I tried to achieve the sensible climate control by making use of a formula node. As soon as I substituted the if statements in the formula node with while statements, the VI did not respond. It did not give any errors, it just didn’t respond.
    Final Assignment2: I tried the same but by making use of while loop structures. The while where my Input DAQ is works fine, but none of the other while loops work.
    Please advise me on possible solutions for my problem/project.
    Thank you in advance.
    D. Weppenaar
    Attachments:
    Final Assignment1.vi ‏254 KB
    Final Assignment21.vi ‏256 KB

    1. Your VI does not respond because your formula node is trapped in an infinite loop and cannot exit if you're out of the deadband. Replace the words "while" with "if" (or similar) and you might be getting somewhere. Sorry, I don't have DAQ installed, but what determines the loop rate?
    2. You have a dataflow issue. Only the inner loop on the left will run. All other loops must wait because they depend on data from the first loop. data is only available at an output tunnel of a loop once the loop finishes and a loop cannot start until all input tunnels contain data. Also the first loop can never stop, because the stop button is outside the loop and will never get read once the inner loop starts. The stop button needs to be in the innermost loop.
    Most likely, all code segments should run synchronized, so delete all the inner loops. They serve no purpose. All yon need is the big outer loop as in the first code.
    There are many ways to directly observe what is going on. For example you could run the VI in execution highlighting mode while watching the diagram.
    Clearly, you need to become more familiar with LabVIEW basics. Maybe do a tutorial? Right now you might think that dataflow is a hindrance while in fact it is one of the most powerful advantages of dataflow programming. You simply need to be familiar with its logic.
    LabVIEW Champion . Do more with less code and in less time .

  • How can I make a while loop wait for input boolean?

    Hi.
    I'm trying to control a robotic arm with labview for my undergrad dissertation, and I have a decent polar coordinate control panel made, but there is one problem; it checks for changes in the coordinates every five seconds, while I want it to only check on the touch of a button (ie, go!, I've changed your coordinates!). The changes are calculated with a while loop comparing the last value of theta, x and z in a while loop with the current one. I can't find a way of putting that into a case structure. If there is a way of making the while loop progress at the push of a button, I think it would work. The VI's attached below.
    Thanks in advance for any help.
    Cathal Scanlon
    ps, sorry about the mess, I'm going to reorganise the while loop into 2 if I can get the control button working.
    Message Edited by CatScan on 02-08-2007 02:45 PM
    Attachments:
    Polar coord assignment1.vi ‏142 KB

    Have you tried using an event structure? To use one, right click on the structure to add an event. Set the event as whatever button you wish to monitor and set the event to "Value Change". If you put this inside a while loop any time the button is pressed, the event structure will run the contents inside the loop. There are a number of options to have the event structure activate.
    *** Warning! I'm probably the last guy you want answering your labVIEW questions, but I figured I might be able to help.

  • Iteration Speed issue when Indexing 3D array wried to a while-loop

    Brief Description of my Program:
    I am working on the real-time signal generation by using LabView and DAQmx (PCI-6110 card). My vi reads the big data file (typically 8MB txt file containing about 400,000 samples (complex double precision). Then, the signal is pre-processed and I end up with a huge 3D array to feed while-loop (typically 3D array dimension is N x 7 x M where N & M >> 7). Inside the loop, that 3D array is indexed and processed before the results are written to the DAQmx outputs. I have a speed issue when indexing the large 3D array (i.e, 3D array having a large sub-array size). My while-loop could not run fast enough to top-up the DAQmx AO buffer (at the output rate of 96kHz). It could run faster only if I use smaller 3D array (i.e, smaller-sized sub-arrays). I do not quite understand why the size of 3D sub-array affects the rate of looping although I am indexing same sub-array size at each iteration. I really appreciate your comments, advices and helps.
    I include my 3D array format as a picture below.
    Question on LabView:
    How does indexing an 3D array which wires to the while-loop affect the speed of the loop iteration? I found that large dimension of sub-arrays in the 3D array slows down the iteration speed by comparing to indexing the same size of sub-array from smaller-sized sub-arrays of the 3D array to perform signal processing inside the while-loop. Why? Is there any other way of designing LabView Program to improve speed of iteration?
    attachment:

    Thank you all for your prompt replies and your interests. I am sorry about my attachment. But, I have now attached a jpg format image file as you suggested.
    I had read the few papers on large data handling such as "LabVIEW Performance and Memory Management". Thus, I had already tried to avoid making unnecessary copies of data and growing arrays in my while-loop. I am not an expert on LabView, so I am not sure if the issues I have are just LabView fundamental limitations or there are any other ways to improve the iteration speed without reducing the input file size and DAQ output rate.
    As you request, I also attach my top-level vi showing essential sections such as while-loop and its indexing. The attached file is as an image jpg format because the actual vi including Sub-VIs are as big as 3MB in total. I hope my attachment would be useful for anyone who would like to reply my question. If anyone would like to see my whole vi & llb files, I would be interesting to send it to you by an e-mail privately and thus please provide your e-mail address.
    The dimension of my 3D array is N x 7 x M (Page x Row x Column), where N represents number of pages in 3D array, and M represents the size of 1D array.  The file I am currently using forms 3D array of N = 28, & M = 10,731.  Refering to the top-level vi picture I attached, my while-loop indexes each page per iteration and wrap-around.  The sub-VI called "channel" inside the while-loop will further index its input (2D array) into seven of 1D arrays for other signal processsing.  The output from that "channel" sub-VI is the superposition of those seven arrays.  I hope my explaination is clear. 
    Attachement: 3Darray.jpg and MyVi.jpg
    Kind Regards,
    Shein
    Attachments:
    3Darray.jpg ‏30 KB
    MyVI.jpg ‏87 KB

  • How to pass a value from inside a while loop outside the loop

    Hello to everybody, I have been searching through the forum but I have not found a certain answer for my problem. I would try to explain my problem as breefly as posible:
    I have to send by a BNC2120 two signals and acquire an other one thats comes from a preassure sensor. That part is done by introducing simulating and acquiring DAQmx inside while loops.It is sycronized by my self, proving such diferent values (is not the optimum, but is only the first prototype) and works as I expected. Well, then I want to sample some of the values of these signals, that is done with relays and local variables to get the value in the instant I want to sample. Here begin my problems: I want to extract the sample values out of the while loops without restarting them, I mean: I do not want to stop the while loops because the acquisition and the generation of the signal must be continuous, but I do not know if it is posible to put the while loops in "standby" until I operate with the values I have sampled and then the signal generator and the acquiere continues from when it has stoped before. Particulary I want to obtain the value of the top while loop (inside a case) when the counter arrives at 15.
    I have proved to do with local variables, global variables, making a state machine, with event cases, with flat secuences...I have been reading about and proving diferent posible solutions for this week and the whole past week and I have not found the solution.
    If any of you know how I can do this thing, I would be loved to listen your opinions. My proyect is above: 
    Thank you a lot in advance.
    Sinceresly,
    Miguel.
    Attachments:
    maq_estados_event_case.vi ‏239 KB

    It definately sounds like what you really want is a Producer/Consumer.  It is an architecture that uses Queues to pass data from a data generation loop (producter, your DAQ loop) and a data processor (consumer).
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Trouble with while loop, not sure what to put in it in my project

    I'm making a class to a simple command line craps game. I must use a while loop to implement craps rules. The rules that i was given are:
    if your first roll is a 4, 5, 6, 8, 9, or 10, you roll again until either you get a 7 (you lose) or you get the number from your first roll. (i thought 7 or 11 wins, like in the next example)
    yeah, thats right, not very good directions. The first directions i had for a different way of doing it using if and else statements were:
    The player rolls the two dice.
    If the sum of the resulting die values is 7 or 11, the player wins.
    If the sum is 2, 3, or 12, the player loses.
    If something else is rolled, the player has to roll again to determine the outcome.
    If the sum of the second roll is the same as what the player rolled the first time, the player wins. Otherwise the player loses.
    (You might get a pair of dice and play a few rounds to try it.)
    here's my code that i have so far for my craps class, in the middle section, i have previous code that i used for if else statements, that is what im trying to replace: package games;public class Craps {
    private Dice dice1;
    private Dice dice2;
    private int gamesPlayed;
    private int gamesWon;
    private boolean lastGameWon;
    private boolean gameOver;
    private int firstRoll;
    private int secondRoll;
    public Craps() {
    dice1 = new Dice(6);
    dice2 = new Dice(6);
    gamesPlayed = 0;
    gamesWon = 0;
    lastGameWon = false;
    firstRoll = 1;
    secondRoll = 2;
         //returns firstroll
    public int getFirstRoll(){
    return firstRoll;
         //returns secondroll
    public int getSecondRoll(){
    return secondRoll;
    public int getGamesPlayed(){
    return gamesPlayed;
    public int getGamesWon(){
    return gamesWon;
    public boolean lastGameWon(){
    return lastGameWon;
         public int nextSum()
         dice1.roll();
         dice2.roll();
         return dice1.getSideUp() + dice2.getSideUp();
    public void play()
              firstRoll = nextSum();
    if (firstRoll == 7 || firstRoll == 11)
              gameOver = true;
              gamesWon++;
              if (firstRoll == 2 || firstRoll == 3 || firstRoll == 12)
              gameOver = true;
                   else{
                   gameOver = false;
              while (gameOver == false)
              secondRoll++;
    public String toString()
    return "games - " + gamesPlayed + ", won - " + gamesWon + ", last game won - " + lastGameWon + " First Roll - " + firstRoll +
    ", Second Roll - " + secondRoll;
    i'm really confused on how to get the while loop will keep starting the game over if it is false, am i using the right approach? Also i have to use a while loop, its for a school project.
    thanks.

    The code you asked for could be:
    package games;
    public class Craps {
        private Dice dice1;
        private Dice dice2;
        private int gamesPlayed;
        private int gamesWon;
        private boolean lastGameWon;
        private boolean gameOver;
        private int firstRoll;
        private int secondRoll;
        public Craps()
            dice1 = new Dice(6);
            dice2 = new Dice(6);
            gamesPlayed = 0;
            gamesWon = 0;
            lastGameWon = false;
            firstRoll = 1;
            secondRoll = 2;
         //returns firstroll
        public int getFirstRoll(){
            return firstRoll;
         //returns secondroll
        public int getSecondRoll(){
            return secondRoll;
        public int getGamesPlayed(){
            return gamesPlayed;
        public int getGamesWon(){
            return gamesWon;
        public boolean lastGameWon(){
            return lastGameWon;
        public int nextSum()
            dice1.roll();
            dice2.roll();
            return dice1.getSideUp() + dice2.getSideUp();
        public void play() {
            gamesPlayed++;
            firstRoll = nextSum();
            if (firstRoll == 7 || firstRoll == 11)
                gamesWon++;
                lastGameWon = true;
            else if (firstRoll == 2 || firstRoll == 3 || firstRoll == 12)
                lastGameWon = false;
            else
               secondRoll = nextSum();
               if (firstRoll == secondRoll)
                  gamesWon++;
                  lastGameWon = true;
               else
                  lastGameWon = false;
        public String toString()
            return "games - " + gamesPlayed + ", won - " + gamesWon + ", last game won - " + lastGameWon + " First Roll - " + firstRoll +
                    ", Second Roll - " + secondRoll;
    }I'm not sure of craps rules, the code above makes a first roll and if game isn't won or lose at once (7 and 11 wins, 2,3 or 12 lose) a second roll is done. If the second roll is equals to the first made then the game is won else the game is lose. Is it right?

  • How to make a graph inside a while loop maintain previous values

    In the beginning I was trying to use an the XY Graph Express VI to create a plot of points.  However, the graph is making a linear retrace between the first point of the new line, and the last point of the previous line.  It then creates the new line as desired.
    I have tried using a for loop with to bundle a cluster to the graph, but the graph resets the plot on each iteration (as expected) and I cannot find a way to make it maintain the previous data.  I tried using shift registers but was unable to find out how to do this, and I have also tried bundling the cluster to an array, but cannot figure out how to make the cluster go to a 1D array of a cluster of 2 elements.
    One option is having is finding a way to make it maintain previous data, but the preferred option is to make it create a new plot on each iteration so as to see the color change for each new plot.
    Solved!
    Go to Solution.
    Attachments:
    shift register attempt.JPG ‏64 KB
    original attempt.JPG ‏42 KB
    Output only current iteration data.JPG ‏86 KB

    I'm taking a stab at this because I'm not exactly sure what you want. But I think it is what I have shown here. You need to use a shift register on your outter while loop as I have shown. Your image where you tried using a shift register shows a misunderstanding of shift registers and how they work though, so I would take a look at these tutorials.
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    plot with SR.png ‏29 KB

  • SubVI with while loop + event structure not working in multi tab VI

    Hello Everyone,
    I am developing an interface for the control of a prober using Labview 2012, and I am stuck with some issue.
    To start with I provide you with a simplified version of my control interface VI, and with the sub-VI used to build and manage the wafer maps.
    The VI consists of several tabs: Prober Initialization, Wafer Handling, Wafer Map, Status, Error.
    The sub-VI can:
    1/ initialize the grid to display the map (sub VI Init Grid not provided here)
    2/ import XY coordinates from a txt file (sub VI Wafer Map Import)
    3/ display the coordinates and index of the die below the cursor
    4/ and when a die position is double clicked, and the boolean "Edit Wafer Map" is true, then the user can change the state (color) of the die between On-wafer die and Selected Die
    My issue:
    If I use the sub-VI by itself, it works fine. However when I use it as a sub-VI in the tab "Wafer Map", the map does not build up and I can no further use the embedded functionalities in the sub-VI.
    I suspect the while loop + event structure of the sub-VI to be the bottleneck here.
    However I don't know which way to go, that's why I'd be glad to have some advice and help here.
    Thank you.
    Florian
    Solved!
    Go to Solution.
    Attachments:
    Control Interface.zip ‏61 KB

    Hi NitzZ,
    Thank you for your reply.
    I tried to save the VIs in LV10, please tell me if you can open them now.
    Inside he event structure there is quite some code, and since I don't want to make the main vi too bulky, I would like to keep it as a sub-VI. 
    As you can see from the sub-VI, the event structure is used for extracting cursor position and tracking the double click action. These events are linked, through a property node, to the image "Wafer Map" which is passed to the main vi through connector pane.
    All values are passed this way as well (through connector pane). Is there another way?
    Maybe "refnum", but I don't really understand how to use them...
    If I use the event structure in the main vi, the wafer map is still not working. I tried it earlier.
    To implement the multi tab front panel, I used a tab control, and a for loop + case structure. For each element of the case structure, there is a corresponding action.
    For the case where I put the code (element=2) for Wafer Map, I also control the execution of the code with a case structure activated by the button "REFRESH". Otherwise I end up with a freezing of the panel right after the start.
    I hope these comments help you understand better.
    Regards,
    Florian
    Attachments:
    Control Interface.zip ‏104 KB

  • Metronomes​, while-loop​s and flat sequences

    I'm making a loop that is supposed to write a poll message to the serial port once every minute and read a message from the same port once every 256 ms. It is supposed to proceed untill a stop button is hit. It is based upon a while loop that contains two different flat sequence structures that each contains a metronome ("wait until next ms").
    The intention of thisis that the program goes through the loop and every 256 ms it reads the serial port and every 60 000 ms it sends a polling message. However, the indicators I've connected to the metronomes doesn't seem so show a linear increase in the ms timer. The poll timer occasionally increases a little (in two minutes it might increase 20 ms). The read timer does not increase at all. Poll count increases very irregularly.
    Does the flat sequences interfer with each other? Can this loop be changed in any manner in order to work properly?
    Attachments:
    poll_loop2.GIF ‏13 KB

    The loop is dominated by the "minute" timer, what will happen is that it will wait the minute, write, go to the 1/4 minute timer do it's read, the back to the minute timer. This is because LabVIEW is a data-flow language. There are a number of different ways to do this, one being having two loops, one writing, one reading, but with out some synchronization between the two they might drift. Another method would be to have an event structure, with the timeout value set to 250 mS, putting the read and write into a case structure in that timeout event. Having a time check, or even a resetable counter (use a shift register on the loop) to determine whether to write or read, with an event for the operator to stop the whole thing. I do a diagram, but have a meeting in a couple of minutes :-)
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Php recordset outputting last value from while loop

    Hi all,
    I have an issue with a site I am making which lists radio buttons which are a set of donation options (some with predefined prices some with user dependant).
    I used jQuery to populate a textbox with the value of the radio buttons so the person does not need to enter a price they want to donate.
    The issue I am having is that I want the page to carry across the fund_id (which is the primary key) to the next page.
    Currently the do / while loop goes through all of the recordset and passes across the last record's fund_id.
    Please see my code below:
    $(function () {
    $('input.radioButton').click(function () {
    var checkedradio = $('[name="fund"]:radio:checked').val();
      $('#totalPrice').val(checkedradio);
    And
    <h3>General</h3>
    <?php do { ?>
      <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_general['fund_price']; ?>" id="<?php echo $row_cat_general['fund_name']; ?>" /><?php echo $row_cat_general['fund_name']; ?> <?php if ($row_cat_general['fund_price']!="") { ?>- &pound;<?php echo $row_cat_general['fund_price']; ?><?php } else {?> <?php };?></label>
      <br />
      <?php } while ($row_cat_general = mysql_fetch_assoc($cat_general)); ?>
    <h3>Sponsorship</h3>
    <?php do { ?>
      <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_sponsorship['fund_price']; ?>" /><?php echo $row_cat_sponsorship['fund_name']; ?> <?php if ($row_cat_sponsorship['fund_price']!="") { ?>- &pound;<?php echo $row_cat_sponsorship['fund_price']; ?><?php } else {?> <?php };?></label>
      <br />
      <?php } while ($row_cat_sponsorship = mysql_fetch_assoc($cat_sponsorship)); ?>
    <h3>Seasonal</h3>
    <?php do { ?>
      <label><input class="radioButton" type="radio" name="fund" value="<?php echo $row_cat_seasonal['fund_price']; ?>" /><?php echo $row_cat_seasonal['fund_name']; ?> <?php if ($row_cat_seasonal['fund_price']!="") { ?>- &pound;<?php echo $row_cat_seasonal['fund_price']; ?><?php } else {?> <?php };?></label>
      <br />
      <?php } while ($row_cat_seasonal = mysql_fetch_assoc($cat_seasonal)); ?> 
    <br />
    <span id="sprytextfield1">
    <label>Enter Amount:
    <input name="total" type="text" id="totalPrice" />
    </label>
    <span class="textfieldRequiredMsg">A donation amount is required.</span></span><br />
    <input name="fund_id" type="hidden" value="<?php echo $row_cat_general['fund_id']; ?>" id="fund_id" />
    <input name="button" type="submit" value="Select" />      
    I hope this doesnt look weird, once I have post this.
    Is there a way I can populate "totalPrice" input box AND have "fund_id" hidden field populated with the fund_id of the selected radio button?
    Thanks for your help.

    Hi,
    I have tried this:
    $(function () {
    $('input.radioButton').click(function () {
    var checkedradio = $('[name="fund"]:radio:checked').val();
      var fundidbox = $('[name="fund_id"]').val();
      $('#totalPrice').val(checkedradio);
      $('#fund_id').val(fundidbox);
      alert($("#fund_id").val());

  • Pause While Loop disrupts everything

    Hello everyone
    I'm made a while loop which is suppose to take some numbers from some arrays, then solve them in a formular and output the data for a certain amount of time - countdown. All this works, but it is important for me that I can pause and start again from the same point in time. This is importan because I may have to pause during the operation and sometimes the countdown would be set for hours where I wouldn't like to restart the entire proces.
    I tried implementing a pause function but now It won't even start. Any body have any ideas?
    Thank you very much,
    Theis
    Solved!
    Go to Solution.
    Attachments:
    PauseTEST.vi ‏36 KB

    aeastet wrote:
    Theis Thorn wrote:
    aeastet wrote:
    Something like this.
    Ye! This looks something like it! I played around with it and adjusted af few things, like making it stop when it gets a zero input from the array. I do, still, have a few problems:
    Whenever it reaches 10 seconds it kinda stops and then suddently ticks up to 20 within 4 seconds, so it even counts to fast. I also added a lamps wich shows which process is running. I build this as an array and when it gets signal 1, it the first lamp turns on, same with 2 but at three suddently multiple lamps light up - weird! It seems like I'm inches away from reaching my goal. Any ideas?
    Well the reason you are getting multipul lamp is because the number going to your lamp array is binary 0,1,2,4,8, etc...
    As far as why it hangs I am not sure I will have to see what you did. Can you save this code with the default values that you are using so that I can see what is going on.
    Ohh! I see, that one I should be able to figure out!
    What do you mean by saving the code with the default values? I'm not sure if it this you mean but here are the values I just tested it with:
    Time (min) 0,2 ^ 0,1 ^ 0,3 ^ 0,4
    Weight (g) 4000 ^ 2000 ^ 4000 ^ 6000
    again, thank you

  • FUNCTION Cursor / WHILE LOOP vs LOOP / Logic help (RESOLVED)

    (I HAVE RESOLVED - making it more efficient, I hope - see FUNCTION) if anyone has a different =, more efficient way to write this, please share...
    I need help with a Function:
    I am trying to get a handle on a rate. This table has and employee column this is usually populated with 'ALL'. On the off chance that it has an actual employee number, I want that rate; otherwise, the rate with ALL. Everything in both records will be the same except the employee field. (if there happens to be an ALL rate and an individual employee rate. Usually there will only be one record).
    As I started to write this, I tested the WHILE loop logic and did not get a value back, but when I test a simple loop, I do. I have not finished the entire logic only getting a handle on a record that has the employee.
    I would like help:
    Understanding why WHILE loop isn't working
    How to go about testing if CURSOR c_job_payroll_rate_emp FOUND - get this value and EXIT otherwise IF NOT FOUND then get value from c_job_payroll_rate_all
    Start to my function is below w/ testing comments(** THIS IS THE RESOLVED FUNCTION.
    FUNCTION job_pay_rate(in_comp_code IN jobpayrate.jpr_comp_code%TYPE,
                        in_job_code IN jobpayrate.jpr_job_code%TYPE,
                             in_phs_code IN jobpayrate.jpr_phs_code%TYPE,
                                  in_cat_code IN jobpayrate.jpr_cat_code%TYPE,
                                  in_trd_code IN jobpayrate.jpr_trd_code%TYPE,
                                  in_emp_code IN jobpayrate.jpr_emp_no%TYPE)
    RETURN jobpayrate.jpr_billing_rate%TYPE
    IS
    v_val jobpayrate.jpr_billing_rate%TYPE;
    CURSOR c_job_payroll_rate_all IS     
         SELECT max(jpr_billing_rate) rate
         FROM jobpayrate
    WHERE jpr_comp_code = in_comp_code
         AND jpr_job_code = in_job_code
         AND jpr_trd_code = in_trd_code      
         AND jpr_phs_code = in_phs_code
         AND jpr_cat_code = in_cat_code
         AND jpr_emp_no <> in_emp_code;     
    CURSOR c_job_payroll_rate_emp IS     
         SELECT max(jpr_billing_rate) rate
         FROM jobpayrate
    WHERE jpr_comp_code = in_comp_code
         AND jpr_job_code = in_job_code
         AND jpr_trd_code = in_trd_code
         AND jpr_phs_code = in_phs_code
         AND jpr_cat_code = in_cat_code
         AND jpr_emp_no = in_emp_code;     
    BEGIN
    FOR rec_e IN c_job_payroll_rate_emp LOOP
    v_val := rec_e.rate;
    IF rec_e.rate IS NULL THEN
    FOR rec_a IN c_job_payroll_rate_all LOOP
    v_val := rec_a.rate;
    END LOOP;
    END IF;
    END LOOP;
    RETURN v_val;
    END job_pay_rate;
    Message was edited by:
    KB

    Rather than using cursors for zero or 1 row queries, use SELECT ... INTO
    Untested
    FUNCTION job_pay_rate(in_comp_code IN jobpayrate.jpr_comp_code%TYPE,
    in_job_code IN jobpayrate.jpr_job_code%TYPE,
    in_phs_code IN jobpayrate.jpr_phs_code%TYPE,
    in_cat_code IN jobpayrate.jpr_cat_code%TYPE,
    in_trd_code IN jobpayrate.jpr_trd_code%TYPE,
    in_emp_code IN jobpayrate.jpr_emp_no%TYPE)
    RETURN jobpayrate.jpr_billing_rate%TYPE
    IS
    v_val jobpayrate.jpr_billing_rate%TYPE;
    BEGIN
    SELECT max(jpr_billing_rate) rate INTO v_val
    FROM jobpayrate
    WHERE jpr_comp_code = in_comp_code
    AND jpr_job_code = in_job_code
    AND jpr_trd_code = in_trd_code
    AND jpr_phs_code = in_phs_code
    AND jpr_cat_code = in_cat_code
    AND jpr_emp_no = in_emp_code;
    RETURN v_val;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        SELECT max(jpr_billing_rate) rate INTO v_val
        FROM jobpayrate
        WHERE jpr_comp_code = in_comp_code
        AND jpr_job_code = in_job_code
        AND jpr_trd_code = in_trd_code
        AND jpr_phs_code = in_phs_code
        AND jpr_cat_code = in_cat_code
        AND jpr_emp_no <> in_emp_code;
        RETURN v_val;
    --OTHER EXCEPTION HANDLING
    END;

Maybe you are looking for

  • Reading the contents of a File without using the  fileref

    Hi , I was trying to read the contents of a file (not upload basically) without using the fileref.upload or any servlets. I wanted to give this file as input(dataprovider) to a datagrid from the local instead of uploading it to the server and fetchin

  • Unmarked content - how to stop this madness

    I have received a several forms in Word from a committee which are to be converted to PDF and made fillable and ADA compliant.  Accessibility report indicates none of the contents are contained in tree structure.  I find unmarked contents to tag them

  • Installing Security and Compliance Manager on Windows 8.1

    Hi I am trying to install Security and Compliance Manager on my Windows 8.1 workstation.  The install is trying to install SQL Express 2008 which seems to not be compatible with Windows 8.1 and that is were the install ends. I tried installing SQL Ex

  • Error:The Disk needs to be repaired

    Hopefully someone can help guide me. I have been noticing a few more spinning beach balls. Nothing dramatic but as a recent convert to Mac (about 1 year) it has me frustrated. A few months ago they got worse and disk utility said my drive was corrupt

  • Availability Check / Sales Order / Planning Strategy 50

    Hi, the material master has been setup with planning strategy 50. now if i sales order is created. the system directly created planned order for the sales order quantity. Now, there is smtimes a situation that some stock is already present in unrestr