Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Tom Lane, 08.04.2010 10:59: Thomas Kellerer writes: CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) RETURNS TABLE(id integer, full_name text) AS $$ BEGIN RETURN QUERY SELECT id, first_name||' '||last_name FROM employee WHERE last_name LIKE name_pattern ||

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Pavel Stehule
2010/4/8 Thomas Kellerer : > Hi, > > I'm playing around with functions returning result sets, and I have a > problem with the following function: > > -- Create sample data > CREATE TABLE employee (id integer, first_name varchar(50), last_name > varchar(50)); > INSERT INTO employee values (1, 'Arthu

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Tom Lane
Thomas Kellerer writes: > CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) > RETURNS TABLE(id integer, full_name text) > AS > $$ > BEGIN >RETURN QUERY > SELECT id, first_name||' '||last_name > FROM employee > WHERE last_name LIKE name_pattern ||'%'; > END > $$ > L

[SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Hi, I'm playing around with functions returning result sets, and I have a problem with the following function: -- Create sample data CREATE TABLE employee (id integer, first_name varchar(50), last_name varchar(50)); INSERT INTO employee values (1, 'Arthur', 'Dent'); INSERT INTO employee values