Лекции.Орг


Поиск:




Категории:

Астрономия
Биология
География
Другие языки
Интернет
Информатика
История
Культура
Литература
Логика
Математика
Медицина
Механика
Охрана труда
Педагогика
Политика
Право
Психология
Религия
Риторика
Социология
Спорт
Строительство
Технология
Транспорт
Физика
Философия
Финансы
Химия
Экология
Экономика
Электроника

 

 

 

 


Using NULL After a Label




In some cases, you can pair NULL with GOTO to avoid having to execute additional statements. Most of you will never have to use the GOTO statement; there are very few occasions where it is truly needed. If you ever do use GOTO, however, you should remember that when you GOTO a label, at least one executable statement must follow that label. In the following example, I use a GOTO statement to quickly move to the end of my program if the state of my data indicates that no further processing is required:

PROCEDURE process_data (data_in IN orders%ROWTYPE, data_action IN VARCHAR2) ISBEGIN -- First in series of validations. IF data_in.ship_date IS NOT NULL THEN status:= validate_shipdate (data_in.ship_date); IF status!= 0 THEN GOTO end_of_procedure; END IF; -- Second in series of validations. IF data_in.order_date IS NOT NULL THEN status:= validate_orderdate (data_in.order_date); IF status!= 0 THEN GOTO end_of_procedure; END IF;... more validations... << end_of_procedure >> NULL;END;

With this approach, if I encounter an error in any single section, I use the GOTO to bypass all remaining validation checks. Because I do not have to do anything at the termination of the procedure, I place a NULL statement after the label because at least one executable statement is required there. Even though NULL does nothing, it is still an executable statement.

Chapter 5. Iterative Processing with Loops

This chapter explores the iterative control structures of PL/SQL, otherwise known as loops, which let you execute the same code repeatedly.PL/SQL provides three different kinds of loop constructs:

· The simple or infinite loop

· The FOR loop (numeric and cursor)

· The WHILE loop

Each type of loop is designed for a specific purpose with its own nuances, rules for use, and guidelines for high-quality construction. As we explain each loop, we'll provide a table describing the following properties of the loop:

Property Description
How the loop is terminated A loop executes code repetitively. How do you make the loop stop executing its body?
When the test for termination takes place Does the test for termination take place at the beginning or end of the loop? What are the consequences?
Reason to use this loop What are the special factors you should consider to determine if this loop is right for your situation?





Поделиться с друзьями:


Дата добавления: 2015-10-01; Мы поможем в написании ваших работ!; просмотров: 388 | Нарушение авторских прав


Поиск на сайте:

Лучшие изречения:

Логика может привести Вас от пункта А к пункту Б, а воображение — куда угодно © Альберт Эйнштейн
==> читать все изречения...

2224 - | 2152 -


© 2015-2024 lektsii.org - Контакты - Последнее добавление

Ген: 0.007 с.