开发者

Error : operator does not exist: dom_id = character varying at character 65 In Postgres SQL

开发者 https://www.devze.com 2023-01-04 17:29 出处:网络
I am trying one stored procedure as follows. CREATE OR REPLACE FUNCTION \"public\".\"get_fees\" (VARCHAR(5000)) RETURNS text[] AS

I am trying one stored procedure as follows.

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$

It shows me following error when i am trying this query

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 ex开发者_开发百科plicit type casts.

What might be the issue.

Thanks Rahul


Try:

...WHERE student_id = any(( string_to_array(student_ids,',') )

https://www.postgresql.org/docs/current/static/functions-array.html


You can't do "where student_id in (varchar)" You have to parse the string into a list.


studetFee must be a record type

0

精彩评论

暂无评论...
验证码 换一张
取 消