how to return whole table from Function not just the id integer column

From: Rehan Saleem <pk_rehan(at)yahoo(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: how to return whole table from Function not just the id integer column
Date: 2012-01-19 09:57:09
Message-ID: 1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

hi ,
how can i return the whole user table from this function not just the id . thanks
CREATE TABLE users(id serial PRIMARY KEY, first_name varchar(10), last_name
varchar(10)); CREATE OR REPLACE FUNCTION new_user(fname varchar, lname varchar)
RETURNS int AS $$
DECLARE r int;
BEGIN -- custom exception -- lname cannot be empty or NEMO IF trim(lname) = '' OR lower(lname) = 'nemo' THEN RAISE EXCEPTION 'bad last_name: "%"', lname; END IF; INSERT INTO users(first_name, last_name) VALUES(lname, fname) RETURNING
id INTO r; RETURN r;
END;
$$ LANGUAGE plpgsql;

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Gendler 2012-01-19 10:33:34 Re: how to return whole table from Function not just the id integer column
Previous Message hari.fuchs 2012-01-19 08:32:27 Re: date range to set of dates expansion