24>
25> CREATE TABLE project (project_no CHAR(4) NOT NULL,
26> project_name CHAR(15) NOT NULL,
27> budget FLOAT NULL)
28>
29> insert into project values ('p1', 'Search Engine', 120000.00)
30> insert into project values ('p2', 'Programming', 95000.00)
31> insert into project values ('p3', 'SQL', 186500.00)
32>
33> select * from project
34> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
project_no project_name budget
---------- --------------- ------------------------
p1 Search Engine 120000
p2 Programming 95000
p3 SQL 186500
(3 rows affected)
1>
2> -- CONTINUE stops only the current execution
3>
4>
5> WHILE (SELECT SUM(budget) FROM project) < 500000
6> BEGIN
7> UPDATE project SET budget = budget*1.1
8> IF (SELECT MAX(budget) FROM project) > 240000
9> BREAK
10> ELSE
11> CONTINUE
12> END
13>
14> select * from project
15> GO
(3 rows affected)
(3 rows affected)
(3 rows affected)
project_no project_name budget
---------- --------------- ------------------------
p1 Search Engine 159720
p2 Programming 126445.00000000004
p3 SQL 248231.50000000009
(3 rows affected)
1>
2> drop table project
3> GO
1>