I am getting error in my PostgreSQL function where I am filtering my data by passing two parameters.Below is my Function and table structure please tell me where and what I am doing wrong
CREATE TABLE table_2(
id_col text,
name_col text);
INSERT INTO table_2(id_col, name_col)
VALUES (1, 'A'),(2, 'B'),(3, 'C'),
(4, 'D'),(5, 'E'),(6, 'F');
CREATE OR REPLACE FUNCTION test_str_1(IN param_name_col text,
VARIADIC integer[], OUT id_col text, OUT name_col text)
RETURNS SETOF record AS
$BODY$
BEGIN
return query
SELECT t2.id_col,t2.name_col from table_2 t2
Where t2.name_col = param_name_col AND t2.id_col::int = ANY($1) ;
END
$BODY$
LANGUAGE plpgsql VOLATILE
SELECT test_str_1('A', 1,2,3);
t2.id_colto betextif you enter only integer values and depend on a cast to integer anyway? Doesn't make sense.