Re: - Mailing list pgsql-general

From Matthew Peter
Subject Re:
Date
Msg-id 20060109232645.78285.qmail@web35211.mail.mud.yahoo.com
Whole thread Raw
In response to Re:  (Jaime Casanova <systemguards@gmail.com>)
Responses Re: Passing a list of values to a function
Re:
List pgsql-general
How come when I pass in a list in it doesn't use it as a list of integers? Do I need to somehow make $1 be interpreted as a list of ints? Rather than just passing a text value that contains the list?

CREATE TABLE my_tbl (u_id int);

INSERT INTO my_tbl (u_id) values (1);
INSERT INTO my_tbl (u_id) values (2);
INSERT INTO my_tbl (u_id) values (3);

CREATE OR REPLACE FUNCTION getlist(text) RETURNS SETOF my_tbl as $$
SELECT * FROM my_tbl
WHERE u_id IN (0, $1);

$$ LANGUAGE SQL;

SELECT * from getlist('1,2,3');
(0 rows)

I'm sure it's probably trival but I'm still learning how psql  :) Thanks


Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.

pgsql-general by date:

Previous
From: Jaime Casanova
Date:
Subject: Re:
Next
From: Bruce Momjian
Date:
Subject: Re: autocommit to off