我正在尝试一个存储过程如下。
CREATE OR REPLACE FUNCTION "public"."get_fees" (VARCHAR(5000)) RETURNS text[] AS
$body$
DECLARE
student_ids ALIAS FOR $1;
studetFee text[];
BEGIN
FOR studetFee IN
SELECT * FROM Student_fee WHERE student_id IN ( student_ids::VARCHAR(5000) )
LOOP
**** some ***
END LOOP;
END;
$body$
我在尝试此查询时显示以下错误
SELECT * FROM get_fees( '1,2,3,4,5'::VARCHAR(5000) );
ERROR: operator does not exist: dom_id = character varying at character 65
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
可能是什么问题。
由于 拉胡
答案 0 :(得分:2)
尝试:
...WHERE student_id = any(( string_to_array(student_ids,',') )
https://www.postgresql.org/docs/current/static/functions-array.html
答案 1 :(得分:0)
你不能做“其中student_id in(varchar)”你必须将字符串解析成一个列表。
答案 2 :(得分:0)
studetFee必须是记录类型