![]() ![]() ![]() Of the loop, then the integer range is given, and finally a statement block is provided. In a PL/pgSQL FOR loop an integer variable is stated first, to track the iteration ![]() Loops in other procedural languages, such as C. Structure of a FOR loop in PL/pgSQL is similar to FOR Use theįOR loop to iterate a statement block over a range of integers that you specify. The FOR loop is arguably the most important loop implemented in PL/pgSQL. In Example 11-44 will run until result is equal to Inequality operator indicates that the WHILE loop will run while the The != symbol in Example 11-44 is the inequality operator. The starting number and ending number are both supplied by the user as function arguments. In Example 11-44, the add_two_loop( ) functionĭemonstrates the use of a WHILE loop designed to add one to a number until the number The syntax of the WHILE loop is shown here: The condition is never evaluated as false, the statement block will repeatedly executed until the client process that it If the condition is evaluated as TRUE, the statements will then be executed. Each time a WHILE loop is entered, its condition will beĮvaluated before the statement block is executed. The WHILE loop is used to loop through a block of statements until a specifiedĬondition becomes false. The function then returns the resulting value. Until it reaches a value higher than ten thousand. Square_integer_loop() function squares an integer (multiplies the number by itself) Here is the syntax for an EXIT statement, within aĮxample 11-42 shows a demonstration of an unconditional loop and anĮXIT statement that ends it based on a condition. Use of labels in EXIT will only work if you have specified a label for the loop you areīy providing a condition in an EXIT statement specifies that the loop should be Here is an example of a defined loop with label syntax: >īy providing a label, you can specify which loop to exit when you have several loops nested inside each other (the In the case of a loop, it may be placed directly before the loop blockīegins to identify that loop block with a chosen label. Loop with EXIT, you may optionally specify a label and/or aĬondition on which the loop should exit from.Ī label is an arbitrary identifier, prefixed with a pair of less-than symbols EXIT statements explicitly terminate unconditional loops. Following is the syntax (without the ELSE keyword) for anĪn unconditional loop statement will continue to loop until it reaches an EXIT Th expression should be a Boolean expression, such as one that checks to see whether a variable has Keyword can be accompanied by WHEN, followed by and an expression to specify when the Unconditional loop will execute the statements within its body until an EXIT statement Use the LOOP keyword to begin a basic, unconditional loop within a function. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |