Я хочу вставить записи в таблицу по функциям.
CREATE OR REPLACE FUNCTION insert_wilda()
RETURNS integer AS
$BODY$
DECLARE
countKab integer;
i integer;
BEGIN
i := 1;
SELECT count(*)+34 into countKab from m_kab
WHILE (i <= countKab)
loop
INSERT INTO "t_historyWilda"("kdHistory","kdProp","kdKab","kdKec","nmWilda","noUrut",bulan,tahun,"isActive")
SELECT 'i',"kdProp","kdKab",'000',"namaKab",'1', EXTRACT(MONTH FROM TIMESTAMP 'now()'), EXTRACT(YEAR FROM TIMESTAMP 'now()'),'1' FROM m_kab
end loop;
RETURN i;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Но я получил ошибку вот так:
ERROR: syntax error at or near "<="
LINE 10: WHILE (i <= countKab)
^
********** Error **********
ERROR: syntax error at or near "<="