#openGauss #入门 #安装 #数据库 #开源
知识来源:docs-opengauss.osinfra.cn/zh/
WHILE_LOOP语句
语法图
图 2 while_loop::=
只要条件表达式为真,WHILE语句就会不停的在一系列语句上进行循环,在每次进入循环体的时候进行条件判断。
示例
CREATE TABLE integertable(c1 integer) ;
CREATE OR REPLACE PROCEDURE proc_while_loop(maxval in integer)
AS
DECLARE
i int :=1;
BEGIN
WHILE i < maxval LOOP
INSERT INTO integertable VALUES(i);
i:=i+1;
END LOOP;
END;
/
--调用函数
CALL proc_while_loop(10);
--删除存储过程和表
DROP PROCEDURE proc_while_loop;
DROP TABLE integertable;
#openGauss #入门 #安装 #数据库 #开源