pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rehan Saleem <pk_rehan@yahoo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: how to return whole table from Function not just the id integer column
Date: Thu, 19 Jan 2012 01:57:09 -0800 (PST)
Message-ID: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com> (raw)

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;

view thread (2+ messages)  latest in thread

Message-ID: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com>
Permalink:  ../1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pk_rehan@yahoo.com
  Subject: Re: how to return whole table from Function not just the id integer column
  In-Reply-To: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox