我正在尝试使用 db.QueryRow() 将参数传递给 Golang 中的以下函数,但是它似乎不接受通常的 ?。DROP FUNCTION IF EXISTS upsertplatform(pToken varchar);CREATE FUNCTION upsertplatform(pToken varchar) RETURNS int as $$ DECLARE _id int = NULL; BEGIN LOOP UPDATE public.platform SET platformToken = pToken WHERE userID = 3 AND platformID = 2 RETURNING id into _id; IF NOT FOUND THEN BEGIN INSERT INTO public.platform (userID, platformID, platformToken) VALUES (3, 2, '1234-123-bbasd') RETURNING id into _id; EXCEPTION WHEN unique_violation THEN UPDATE public.platform SET platformToken = '1234-123-bbasd' WHERE userID = 3 AND platformID = 2 RETURNING id into strict _id; END; END IF; EXIT WHEN _id IS NOT NULL; END LOOP; RETURN 1; END$$ LANGUAGE PLPGSQL;这是我遇到问题的查询,我不确定如何将参数传递给它:res := db.QueryRow(`SELECT * FROM upsertplatform( ? )`, "test123")我该如何正确地做到这一点?
- 1 回答
- 0 关注
- 255 浏览
添加回答
举报
0/150
提交
取消