Re:
От | Matthew Peter |
---|---|
Тема | Re: |
Дата | |
Msg-id | 20060109232645.78285.qmail@web35211.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | Re: (Jaime Casanova <systemguards@gmail.com>) |
Ответы |
Re: Passing a list of values to a function
Re: |
Список | 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
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 по дате отправления: