pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to return whole table from Function not just the id integer column
2+ messages / 2 participants
[nested] [flat]

* how to return whole table from Function not just the id integer column
@ 2012-01-19 09:57 Rehan Saleem <pk_rehan@yahoo.com>
  2012-01-19 10:33 ` Re: how to return whole table from Function not just the id integer column Samuel Gendler <sgendler@ideasculptor.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Rehan Saleem @ 2012-01-19 09:57 UTC (permalink / raw)
  To: 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;

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: how to return whole table from Function not just the id integer column
  2012-01-19 09:57 how to return whole table from Function not just the id integer column Rehan Saleem <pk_rehan@yahoo.com>
@ 2012-01-19 10:33 ` Samuel Gendler <sgendler@ideasculptor.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Samuel Gendler @ 2012-01-19 10:33 UTC (permalink / raw)
  To: Rehan Saleem <pk_rehan@yahoo.com>; +Cc: pgsql-sql

On Thu, Jan 19, 2012 at 1:57 AM, Rehan Saleem <pk_rehan@yahoo.com> wrote:

> hi ,
>
> how can i return the whole user table from this function not just the id . thanks
>
> Chapter 39, specifically 39.3, of the postgresql documentation provides
all of the information necessary to answer this question.  If, after
reading that chapter and attempting to solve the problem yourself, you
still have no success, then please post your question to the list along
with your best attempt at a solution.  You cannot expect to make efficient
use of a sophisticated rdbms without first reading at least the most
relevant sections of the documentation, and the mailing lists do not have
enough experienced users to devote bandwidth to doing your work for you.

http://www.postgresql.org/docs/current/static/plpgsql-declarations.html

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-01-19 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-01-19 09:57 how to return whole table from Function not just the id integer column Rehan Saleem <pk_rehan@yahoo.com>
2012-01-19 10:33 ` Samuel Gendler <sgendler@ideasculptor.com>

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