gpt4 book ai didi

postgresql - while 在 postgresql 中的函数

转载 作者:行者123 更新时间:2023-11-29 11:32:26 24 4
gpt4 key购买 nike

我想按函数向表中插入记录。

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 "<="

最佳答案

你错过了';'在这一行之后

SELECT count(*)+34 into countKab from m_kab

关于postgresql - while 在 postgresql 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6094566/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com