数据仓库服务 GaussDB(DWS)-循环语句:FORALL批量查询语句

时间:2023-11-01 16:15:38

FORALL批量查询语句

语法图

图5 forall::=

变量index会自动定义为integer类型并且只在此循环里存在。index的取值介于low_bound和upper_bound之间。

示例

 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930
CREATE TABLE hdfs_t1 (  title NUMBER(6),  did VARCHAR2(20),  data_peroid VARCHAR2(25),  kind VARCHAR2(25),  interval VARCHAR2(20),  time DATE,  isModified VARCHAR2(10)) DISTRIBUTE BY hash(did);INSERT INTO hdfs_t1 VALUES( 8, 'Donald', 'OConnell', 'DOCONNEL', '650.507.9833', to_date('21-06-1999', 'dd-mm-yyyy'), 'SH_CLERK' );CREATE OR REPLACE PROCEDURE proc_forall()AS BEGIN     FORALL i IN 100..120         insert into hdfs_t1(title) values(i);END; /--调用函数CALL proc_forall();--查询存储过程调用结果SELECT * FROM hdfs_t1 WHERE title BETWEEN 100 AND 120;--删除存储过程和表DROP PROCEDURE proc_forall;DROP TABLE hdfs_t1;
support.huaweicloud.com/devg-811-dws/dws_04_0537.html