Unable to understand the result of the loop


Hi all

I got the tracking code:

Code

Set serveroutput ON

DECLARE
TYPE IS VARRAY months_array (12) STRING (3 CHAR);
MONTHS months_array: = months_array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
BEGIN
< < list_month > >
FOR month number IN REVERSE 6.12
LOOP
dbms_output.put_line (' number month = ' | number month |) "Items =' | MONTH (MONTHNO));
CONTINUE list_month
WHEN number month < 9;
END LOOP;
END;

Code output

number months = 12 = Dec

number month = 11 = Nov

number months = 10 items = Oct

number month = 9 elements = Sep

number month = 8 = August

number month = 7 cells = Jul

number months = 6 items = Jun

My question is if you notice the code condition which is CONTINUE list_month number months WHEN < 9 means loop must be output if number month < 9 and according to code loop starting with number months = 12 so system should display the 1st line of output that is number months = 12 elements = Dec , then exit because the loop exit condition is true that is list_month MORE WHEN number month < 9. Please, help me to understand the output.

Hi Muzz,

try something like this

BEGIN
  FOR monthno IN REVERSE 6..12
  LOOP
    exit when monthno < 9;
    dbms_output.put_line('monthno= '||monthno||' Elements='||MONTH(monthno));
  END LOOP;
END;

concerning

Kay

Tags: Database

Similar Questions

  • Unable to understand the code output

    Hi all

    I was reading one of the codes and unable to understand its outcome, I'm really grateful if someone guide me to understand. Thanks in advance.

    Code example

    create or replace package Mp_pkg

    IS

    P_nn TYPE TABLE IS NUMBER

    INDEX BY VARCHAR2 (10);

    END;

    ----------------

    DECLARE

    l_numbers Mp_pkg.p_nn;

    Start

    FOR indx IN 1... 50

    loop

    (indx) l_numbers: = indx;

    END loop;

    dbms_output.put_line (l_numbers. (Last);

    END;

    ----------

    Result

    9

    -----------

    According to my understanding, result should be 50 because the last value of l_number is 50...

    Please guide...


    Hello

    As John said, the VARCHAR2 '9 ' (or any string '9') is longer than the string of 50', for the same reason that the string 'Z' is longer than the string "THE".

    What do we mean when we say this string x is greater than string y?  We mean that

    1. The 1 x chraracter comes after the 1st character of y (in sort order), or, if these characters are equal
    2. x has a 2nd character, but is not, or, if both are more than 1 character
    3. The substring SUBSTR (x, 2) > SUBSTR (y, 2)

    What (if any) strings mean is not serious, so

    • '9' is greater than '50',
    • 'zero' is greater than 'a '.
    • 'small' is greater than 'big '.
    • 'MIN' is greater than 'MAX '.
    • 'yesterday' is greater than 'tomorrow', and
    • "1 January 1900' is superior to" December 31, 2015 ".

    According to rule 1 Correction: rule 3 is the reason why 'MIN' is greater than 'MAX '; the others are all due to rule 1

  • Unable to understand the output...

    Hi gurus

    I was reading a little code and unable to understand a single line, can someone guide me to understand this line.

    Code example

    Set serveroutput on

    DECLARE

    n number;

    BEGIN

    n: = 2 * 33.

    dbms_output.put_line (n);

    end;

    Result

    8589934592


    Now, I would like to know how the calculation performed for n: = 2 * 33 in the background so it become 8589934592 result. Thanks in advance.

    One of these curiosities PL/SQL in SQL vs. In PL/SQL * is same as it is built based on POWER. 2 * 33 is identical to POWER (2.33). It is documented in the Precedence of the operators:

    Table 2-3. precedence of operators

    Operator Operation

    **

    Exponentiation

    SY.

  • Unable to understand the syntax index

    Hello
    I can't understand the meaning of the following syntax to index... and how it works
    CREATE UNIQUE INDEX X_GRS_DMSC_U02 ON Ta_GR_MSC
    (DECODE("GR_TP",'U',NULL,"ON_ID"), DECODE("GR_TP",'U',NULL,"GRS_MSC"))
    Why the syntax above is used... And how does it work?

    Could you please update me as soon as possible...

    It looks like a basic index function. It is designed to ensure that there is a unique combination of the columns 'ON_ID' AND 'GRS_MSC', if the value in the "GR_TP" column is not equal to "U".

    I will try to create the 'TA_GRS_MSC' table and apply the index to illustrate the above as follows:

    SQL> create table ta_gr_msc (gr_tp varchar2(10),on_id varchar2(10), grs_msc varchar2(10));
    
    Table created.
    
    SQL> CREATE UNIQUE INDEX X_GRS_DMSC_U02 ON Ta_GR_MSC
      2  (DECODE("GR_TP",'U',NULL,"ON_ID"), DECODE("GR_TP",'U',NULL,"GRS_MSC"));
    
    Index created.
    
    SQL> insert into ta_gr_msc values ('U','1', '1');
    
    1 row created.
    
    SQL> insert into ta_gr_msc values ('U','1', '1');
    
    1 row created.
    
    SQL> insert into ta_gr_msc values ('X','1','1');
    
    1 row created.
    
    SQL> INSERT INTO TA_GR_MSC VALUES ('X','1','1');
    INSERT INTO TA_GR_MSC VALUES ('X','1','1')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (USER01.X_GRS_DMSC_U02) violated 
    
    SQL> INSERT INTO TA_GR_MSC VALUES ('X','1','2');
    
    1 row created.
    

    As noted above, when the value in the column 'GR_TP' is equivalent to 'U', you can insert any combination of the values in double columns 'ON_ID' and 'GRS_MSC '. However, if the value in the "GR_TP" column is not equal to 'U', you get a unique constraint exception when you try to insert values in double columns 'ON_ID' and 'GRS_MSC '.

    I hope this helps.

  • Unable to understand the Plan to explain

    Hi gurus

    I'm trying to understand some basics of explain plan and get a hard time, I was reading the book tuning performance and incapable of understanding explain plan for the following query:

    Example query

    EXPLAIN PLAN FOR

    SELECT *.

    WCP

    WHERE THERE IS NOT (SELECT 0

    OF THE Department

    WHERE dept.dname = 'SALES' AND dept.deptno = emp.deptno)

    AND NOT EXISTS (SELECT 0

    Bonus OF

    WHERE bonus.ename = emp.ename);

    -------------------

    Select * from table (dbms_xplan.display);

    ---------------

    Output

    Hash value of plan: 734347697

    -----------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    -----------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |       |     5.   290.     7 (15) | 00:00:01 |

    |*  1 |  HASH ANTI JOIN |       |     5.   290.     7 (15) | 00:00:01 |

    |*  2 |   HASH ANTI JOIN |       |     5.   255.     5 (20) | 00:00:01 |

    |   3.    TABLE ACCESS FULL | EMP |    14.   532.     2 (0) | 00:00:01 |

    |*  4 |    TABLE ACCESS FULL | DEPT |     1.    13.     2 (0) | 00:00:01 |

    |   5.   TABLE ACCESS FULL | BONUS |     1.     7.     2 (0) | 00:00:01 |

    -----------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access("BONUS".") ENAME "=" EMP ". ("' ENAME ')

    2 - access("DEPT".") DEPTNO "=" EMP ". ("' DEPTNO ')

    4 - filter("DEPT".") DNAME "= 'SALES')

    -------------------------

    Grateful if someone help out me. Thank you

    In addition, I really appreciate if someone proposes a simple tutorial to explain plan. Thanks again

    Concerning

    Shu

    Hi Shuumail,

    Here is the tutorial http://allthingsoracle.com/execution-plans-part-1-finding-plans/

  • Unable to understand the original clause


    Hi gurus

    I tried to understand what follows where the clause, but still facing problem to understand that and I really appreciate if someone explain it to me step by step and in detail. Thanks in advance:

    Where Clause

    NOT the CASE (min_age = min_min_age

    OR (min_age - 1, rule_id, status_code)

    IN (SELECT max_age, rule_id, status_code

    OF got_analytics

    )

    )

    Concerning

    Shu

    not ( -- simple
      min_age = min_min_age  -- simple
      or -- simple
      (min_age-1, rule_id, status_cod) in (select max_age,rule_id,status_cod from analytics) -- complex
    )
    

    Description for COMPLEX line

    The triplicate (min_age-1, rule_id, status_code)

    must match one of the Geometry produced by:

      (select
          max_age,rule_id,status_code -- your triplicate
        from analytics)
    

    You'll have to check that my logic, but I think that the 'complex' line can be re-written as a clause EXISTS

    EXISTS ( select null
             from analytics A
             where A.max_age = X.min_age - 1
               and A.rule_id = X.rule_id
               and A.status_code = X.status_code )
    

    MK

  • Need help to understand the query result

    Hi gurus

    I was reading one of the question here in this forum and its link is below:

    Query required for scenario

    I had some confusion related to this code and don't understand the logic of the out put, see query below:

    Query

    with sub_services as

    (

    Select su_seq 12323, 'HLR1' so_id, 1 seq Union double all the

    Select su_seq 12323, "HLR2' so_id, seq 2 Union double all the

    Select su_seq 12323, "A09" so_id, seq 3 of all the double union

    Select su_seq 12333, "MO1" so_id, seq 4 Union double all the

    Select su_seq 12333, "MO2' so_id, seq 5 Union double all the

    Select su_seq 12333, "A09" so_id, 6 seq in union double all the

    Select su_seq 12333, 'M0CR' so_id, seq 7 Union double all the

    Select su_seq 12999, "LOL1' so_id, seq 8 Union double all the

    Select su_seq 12999, "LOL2' so_id, seq 9 double

    )

    Select *.

    of sub_services b

    where exists (select 1 from sub_services

    where su_seq = b.su_seq

    and so_id = 'A09.

    )

    order by 2;

    The query result

    12323 A09 3

    12333 6 A09

    12323 HLR1 1

    12323 HLR2 2

    12333 M0CR 7

    12333 4 MO1

    12333 5 MO2

    According to my understanding, the above query should return records in red only because of her is below command

    It exists (select 1 from sub_services

    where su_seq = b.su_seq

    and so_id = 'A09.

    but don't know why he's back 7 files, can someone help me understand the result...

    It is query is functionally identical to the PL/SQL block, but much more effective.

    declare

    number of l_res;

    Start

    for line (select *)

    sub_services) loop

    Start

    Select 1 from l_res

    of sub_services

    where su_seq = row.su_seq and

    so_id = "A09" and

    rownum = 1;

    exception when

    NO_DATA_FOUND then

    null;

    end;

    end loop;

    end;

    Essentially every row in the outer query are tested against him exists query.  Given the correlation between two requests is based only on su_seq each line with a su_seq value returned by him is returned in the output.

    Another way to think he uses instead a join condition.  This query is equivalent to the query to exist

    Select the main

    of main sub_services

    Join select (separate su_seq

    of sub_services

    where so_id = "A09") cond

    We main.su_seq = cond.su_seq;

    John

  • RunState.ProcessModelClient. how to access the results of markets located in the loops?

    Hello

    In my sequence, I have to perform an analysis of the results before I have the MainSequence and return to the process template. Basically, I need to check made some steps has passed.

    I access the results using RunState.ProcessModelClient. Using what I have access to the list of results. I would like to write that I have access to each result but I can't because I spotted the results of steps which are curly are not accessible (they are not there); However, they are on the report.

    How is it possible? How do I access results in a loop? Where are they?

    K.

    Hello

    not too painful:

    the loop results in the usual place online, it's just the layout that will look like a little confusing:

    You use some revisions of my TestStand (you are in 3.1)

    The Runstate.ProcessModelClient is actually a copy of the space of time edit, not space running - it's the SequenceFile type, which means that even if you can see the layout of the result containers that belong to each step, they are there permanently, and not filled in this place from the moment of execution.

    At the level of the mainsequence, you're still in your client, then you can go to Locals.ResultList directly.

    In there, you have the singular element that is the result of the first and the only stage of your Mainsequence of your.

    Inside there is the. TS. SequenceCall container. It is effectivey the resultlist gait that calls (always Mainsequence) seq1 so inside that, there is an another ResultList.

    It's the ResultList for sequence "Seq1".

    Which has a single item since this sequence has only one step inside of type SequenceCall.

    [0]. TS. SequenceCall.ResultList.

    From there you can see a lot of results even if you have only 4 effective steps in this sequence.

    12 results covers:

    3 iterations of ('for' 'Test2' 'end').

    and then the last 3 items are "Test1" loop 2 times more.

    When you set a stage of the loop and include you the results of each iteration, you get these results (2 in your case) more a global success-failure based on the criteria (your care ot 100% must pass in order to study the step successful when all iterations are complete.)

    Note in your pre Expression where you change the name of the step on the fly, your labeled Test2 incremental changes the name from 'Test1' + Str (Locals.LI), and the Test1 marked step uses the same expression for this will look slightly confused that you cross your results.

    Hope that helps.

    Thank you

    Sacha

  • Unable to display the results of a detailed report or the results of a questionnaire which is inbedded in the project.  I checked the preferences of quiz and enabled for the draft declaration.  I use SCORM 1.2.  My LMS is not listed (MCN) and so I chose '

    Unable to display the results of a detailed report or the results of a questionnaire in a bed within the project.  I checked the preferences of quiz and enabled for the draft declaration.  I use SCORM 1.2.  My LMS is not listed (MCN) and so I chose 'other LMS standard.  Any ideas on why I see the results?

    Publish your SCORM SCORM Cloud and test if it will show you the results you want.  If so, then your problem is with your LMS.  If this is not your problem may be due to something in the settings of your current project.  Eliminate one thing at a time.

  • Unexpected for the result of the loop

    I am trying to increase the alpha property of a text field for a fade effect using a loop when I discovered a problem with the loop itself. I added a trace statement to the following bit of code:

    < CODE >

    Loop for increase the alpha of 1 textframe property until it reached a value of 100 from 0. I put
    TextFrame._alpha = 0 in this.createTextField("hello_txt",0,10,10,100,20) () in front of this code.

    for (i = 0; i < = 100; i ++) {}

    TextFrame._alpha = textframe._alpha + i;
    trace ("Although (i) =" + (i) + ", textframe._alpha =" + textframe._alpha + "you NOOB." "");

    }

    < END CODE >

    This loop gives the following:

    Although (i) = 0, textframe._alpha = 0 you NOOB.
    Although (i) = 1, textframe._alpha = 0,78125 you NOOB.
    Although (i) = 2, textframe._alpha = 2,734375 you NOOB.
    Although (i) = 3, textframe._alpha = 5,46875 you NOOB.
    Although (i) = 4, textframe._alpha = 9.375 you NOOB.
    Although (i) = 5, textframe._alpha = 14,0625 you NOOB.
    ...
    Although (i) = 100, textframe._alpha = 5031,25 you NOOB.

    I have removed the traces 6-99 for the purpose of saving space here. As you can see, textframe._alpha does not (i). This code always gives exactly the same result to decimal.

    (I know I must add a setTimeout() or setInterval() to delay the effect of melted and I need to break the text on screen and overthrow the alpha for fade effect, etc.).

    It's true I'm 'Factor 10 of NOOB'. However, I'm making progress! Thanks ahead for any help, noting in my pea brain why it happens. I guess I have a problem of not data synchronization type problem but I would not stake my life on the fact that I am mistaken :) All this code is in a movieclip nested Framework 1. I plan on the development of this fade in/out effect over the same timeline while changing the text itself. I decided to go this route instead of trying to do this with clips on the stage, I thought it would give me more control and less drawing. See you in 8 days.

    Try:

  • "I understand the risks" missing option - page is read from cache

    trying to access the Web site, I am facing a security warning because the certificate is self-signed.
    This is an internal site, which is currently the subject of tests - so it's ok to add an exception.
    the question is, the option to select "I understand the risks" is totally absent, the only available action is "get me out of here"

    Since it is an internal site under our control, I did a few tests more:
    It seems that firefox redirects the initial http request to https
    This does not happen on other browsers (chrome and IE), also tested in a clean install of firefox running without the extensions.

    even after completely cleaning the cache and temporary files, question remains.
    This site (over http) does not load on firefox, always redirected to https

    even after deleting the server mod_ssl apache and by eliminating completely any mention of the ssl on that server, connection with firefox always redirects http to https (now results in the error "Unable to connect to Server" - but still not to load the basic site http version)

    Amir.

    I forgot the screenshot of SQLite Manager.

  • Automatic indexation 2D array in the loop For - what is happening?

    I found many sources dealing 1 d tables in a loop For or a While loop, using automatic indexing, but nothing on the tables of higher order.

    I work with a program that feeds a 2D array in a loop (see table).  From what I see, it looks like this the results of automatic indexing in a 1 d, the first column of table 2-D table.

    This is the expected behavior, and it would hold true for arrays of higher order, table 3D for example?

    Is it possible to refer to the second column rather than the first?

    wildcatherder wrote:

    I found many sources dealing 1 d tables in a loop For or a While loop, using automatic indexing, but nothing on the tables of higher order.

    I work with a program that feeds a 2D array in a loop (see table).  From what I see, it looks like this the results of automatic indexing in a 1 d, the first column of table 2-D table.

    N ° it auto-index through a line at a time table.  You will get a 1 d table which consists of all of the columns that make up each row in each iteration.

    This is the expected behavior, and it would hold true for arrays of higher order, table 3D for example?

    Yes.  Automatic indexing on a 3D Board will give you a table on each iteration of each page 2D.

    Is it possible to refer to the second column rather than the first?  This question applies once you understand the first response.

  • PtbyPt filter FIR in the Loop Simulation

    Hello

    Currently, I am trying to simulate the power in my engine when I apply a voltage step for 20 MS for that I intend to use a FIR filter in the control and simulation module that simulates the other parts of the engine.

    However, I have found that the FIR filter seems to be strange behavior. When I change the order of Runge-Kutta 1 simulation to 2 of Runge-Kutta it effects the output of the filter FIR PtbyPt VI. The two attached images show how the results of the convolution of the IR and the tension, the FIR outside the simulation loop filter and FIR filter in a loop using Runge-Kutta 1 are the same. However, the second image shows that the FIR filter in the loop simulation Runge-Kutta 2, has a different answer.

    Why does this happen? As I understand it, the type of simulation should have little effect on the application of a FIR filter based on pt by pt. I have not changed the timestep or other parts of the simulation. I want to use a simulation of order higher than for other parts of Runge-Kutta 1 would be insufficient for the simulation.

    I'm using LabVIEW 2011 SP1.

    Thank you

    Rhys

    When you try to use RK-2 or higher order, the screw that dumped you inside the control and the Simulation loop, by default, they will all run in the "minor" time steps too. In your case, 'two times' which means the VI will be executed each time step.

    To properly configure these screws, you must "right click" on the VI and select "Installation of the Sub - VI node. This will bring to a Setup page that the second half you will choose in 'Type of Simulation Subvi execution' to 'remove' the "Include minor steps" box and press OK. When you do this, the Sub - VI will be annotated on the upper right with blue 'C' and when you run, it should provide a similar result as RK-1.

    Note that in this dialog box, you can also select discreet, which, in many cases, it is the right selection for 'discrete' systems

    I hope this helps...

  • Value of the loop variable for begins with the last entry of the previous run

    I have a problem with a loop for... I am a beginner with Labview and perhaps do not follow the order of events (since it runs not on a line-by-line as typical of programming languages), but I think that my problem is trivial.

    Say I'm running a loop for 16 iterations and I want to build a table which, for example, consists of four 0s, 1 4s, four 2s and 3 four s.   I initialize the array outside and using shift registers to be added to the matrix in the loop for.

    However, the first time I run the program I get funky results.  In subsequent runs, the first value in my table is a 3, and the rest of the rest of the table is moved down by 1, so I did that three 3s at the end (for example).

    Can someone help me understand how to solve this problem?

    Thank you

    George


  • Unable to find the option to upgrade Windows Vista to Windows 7.

    Original title: upgrading to windows 7 NO 8

    I am writing on behalf of my grandparents. My Grandpa has thought about his laptop computer to upgrade Vista to Windows 7 but I can't find downloads to upgrade to windows 7, only windows 8, which I am sure that they used to focus on after the reaction they had trying to use my windows phone.

    Can anyone find a link with a price please? :)

    Hi Sue & Johnarbon,

     

    Thanks for posting your question in the Microsoft Community.

    From your problem description, I understand that you are unable to find the option upgrade Windows Vista to Windows7. Please let me know if you do not experience this problem.

    I understand the inconvenience caused to you. I'll help you solve the problem!

    Try the links below and check:

     

    Links to buy the upgrade to Windows 7:

    Windows 7 Home Premium: http://www.microsoftstore.com/store/msstore/PD/Windows-7-Home-Premium/ProductID.235488300/VIP.true

    Windows 7 Professional: http://www.microsoftstore.com/store/msstore/PD/Windows-7-Professional/ProductID.216645600/VIP.true

    Windows 7 Ultimate: http://www.microsoftstore.com/store/msstore/PD/Windows-7-ultimate/ProductID.216647200/VIP.true

    For further assistance regarding the purchase, call: 1-877-696-7786.

    Reference links:

    Step_ By_ step procedure to upgrade Windows Vista to Windows 7:

    http://Windows.Microsoft.com/en-us/Windows7/help/upgrading-from-Windows-Vista-to-Windows-7

    Windows 7 Upgrade Advisor: http://Windows.Microsoft.com/en-us/Windows/downloads/Upgrade-Advisor

    Upgrading to Windows 7: http://Windows.Microsoft.com/en-us/Windows7/products/upgrade

    If the problem persists, post your reply with the results. We are happy to help you further in the advanced troubleshooting steps!

    It will be useful.

Maybe you are looking for

  • Cannot move Adware Mac to the trash

    I use the latest version of El Capitan on my iMac.  I force strong Mac Adware Cleaner, but when I drag the application to the trash it flies right back where the icon was. Help, please

  • Install the SNYC does not not on new FF

    The Department'S work deleted and reinstalled FF on my work PC to my request for a number of e-mail client. When I logged onto my account FF Sync and nothing to synchronize. Let him on it during the night thinking that he could do then. When I got ho

  • Satellite A500-1GL - some FN keys only work does not correctly

    HelloI have the Toshiba Satellite A500-1GL, and I have a problem with the FN key (actually not the key itself, is the other keys, the keys that have orders)for example:FN + ESC = mute, and it works great!But... FN + F8, should turn the wireless, but

  • Satellite C670 - Win XP drivers for necessary video card

    Please help Win XP drivers for video Satellite C670 necessary, no drivers on the site, whats model videocard in Satellite C670-15E?

  • Language of expression in ADF

    Hello everyonePlease, I want more information to learnLanguage of expression in ADFfor example, how can add the parameter orIf statement.. .etc