分类: 数据库开发技术
2015-03-05 18:51:41
drop table test_a;
create table test_a(name1 char(1));
create table test_m(name1 char(1));
select * from test_a;
insert into test_a values('a');
insert into test_a values('b');
insert into test_a values('c');
insert into test_a values('d');
#### netezza cursor
declare
cur RECORD
begin
FOR cur IN select_stmt LOOP / FOR cur IN EXECUTE sql_var LOOP
....
end loop ;
end
CREATE OR REPLACE PROCEDURE TEST_1() RETURNS INT8 LANGUAGE NZPLSQL
AS
BEGIN_PROC
DECLARE
rec RECORD;
BEGIN
FOR rec in SELECT * from test_a LOOP
insert into test_m values (rec.name1);
raise notice '%' ,rec.name1 ; -- to print something , must be complied with the format raise notice '%' , text
END LOOP;
return 1;
END;
END_PROC;
call TEST_1() ;