views:

33

answers:

3

Hey All,

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 explicit type casts.

What might be the issue.

Thanks Rahul

A: 

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

Paul Tomblin
+3  A: 

Try..

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

http://www.postgresql.org/docs/8.4/static/functions-array.html

rfusca
Hey Thanks :) it works for me.
Rahul Waghmare
Can you accept the answer?
rfusca
A: 

studetFee must be a record type

mavirroco