From pk_rehan@yahoo.com Thu Jan 19 09:57:23 2012 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A486243CEB8 for ; Thu, 19 Jan 2012 05:57:23 -0400 (AST) Received: from nm10-vm2.bullet.mail.ne1.yahoo.com ([98.138.90.158]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RnokE-0004dF-Aa for pgsql-sql@postgresql.org; Thu, 19 Jan 2012 09:57:23 +0000 Received: from [98.138.90.56] by nm10.bullet.mail.ne1.yahoo.com with NNFMP; 19 Jan 2012 09:57:09 -0000 Received: from [98.138.89.160] by tm9.bullet.mail.ne1.yahoo.com with NNFMP; 19 Jan 2012 09:57:09 -0000 Received: from [127.0.0.1] by omp1016.mail.ne1.yahoo.com with NNFMP; 19 Jan 2012 09:57:09 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 280056.84637.bm@omp1016.mail.ne1.yahoo.com Received: (qmail 16354 invoked by uid 60001); 19 Jan 2012 09:57:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1326967029; bh=2j/9RJAV/UCQrrb47SYwxnlDQLTgrJyNzRRimRFpPJU=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=gUfRfBoaGhq9CWv3sHm/HB+Kdz9KiPnmz/yK2uWQIQC4knIVFeYmlCgcmw2rfRxWJVWbYoUgqshjC+V+LLn9hbUn1LaikUDgBMJjGx6GY/Bn3HAiu3H6kDuD11pynsA5LVca2oA27z9sMYR8cJYXBkXwRrLJZLSZGr9rOMINisg= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=3vdWzsiBQ+fCaGFYO86n9O5ZhvK+T84Mmv8FOmUxQPmTnN62AJLC++UgT8k9mDC3hzTJG571mZ9jR8fKQb1CCoxUttpBnOFKxSXw5PRetjvqcHS/B1WZZ4sPGaSwzOHlDPd6yHZSrj8iEYLkMgerkatfEMZf0hXmKZqEuhUnpKw=; X-YMail-OSG: C3IPqFQVM1mE7WgAzlMem5RgfDWSdWKsCbcp8ZlcrnufHiV RLorq1UklI3pJW7waVa2igSjqi7HOtpFxMYAa1NLamq7IaloEcDfIGG0Tk6F _0Yh68Ua7fDXOEFN0dgNWp58JyVFoPKVcukMPnVFrB4Jv_i0UCKuKDBvyGe5 W_HuW_urNqmlIuqVudthdgMIgw9lHjYbNWB_J282UmTl59fbZnhkfF_d6Oy9 x1kTNtQYEsqa5Qm0go8sBf4HhV6HUbQRSeDhw.62SUK07PU.f1aFLXGbEekT DGxVGY3kl2dra6Jo98sWsF6FwD.Owj4be4Wz2quR272XMzjoIm3xX3m_gjaz f.GmlWleUXd1WwDix9x601gPIP374pywcw9PHuhF2Fxeimq.4_2H5fi9wkCX qJK4zssx1HbGD1T_QJ76VzbICGSfLBsih1VirByHxnSWc_InrkUfvc5Ww0AC JOpDcoupBCkXUcsLmYmkDdd0lyQ-- Received: from [180.178.150.115] by web121601.mail.ne1.yahoo.com via HTTP; Thu, 19 Jan 2012 01:57:09 PST X-Mailer: YahooMailWebService/0.8.115.331698 Message-ID: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com> Date: Thu, 19 Jan 2012 01:57:09 -0800 (PST) From: Rehan Saleem Reply-To: Rehan Saleem Subject: how to return whole table from Function not just the id integer column To: "pgsql-sql@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1977980688-29967351-1326967029=:84665" X-Pg-Spam-Score: -2.0 (--) X-Archive-Number: 201201/86 X-Sequence-Number: 36257 ---1977980688-29967351-1326967029=:84665 Content-Type: text/plain; charset=us-ascii 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; ---1977980688-29967351-1326967029=:84665 Content-Type: text/html; charset=us-ascii
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;
---1977980688-29967351-1326967029=:84665-- From sgendler@ideasculptor.com Thu Jan 19 10:33:50 2012 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0A5D043CEB8 for ; Thu, 19 Jan 2012 06:33:50 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RnpJU-0005GG-UG for pgsql-sql@postgresql.org; Thu, 19 Jan 2012 10:33:50 +0000 Received: by iagf6 with SMTP id f6so7494596iag.19 for ; Thu, 19 Jan 2012 02:33:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.145.131 with SMTP id f3mr25850886icv.8.1326969214710; Thu, 19 Jan 2012 02:33:34 -0800 (PST) Received: by 10.50.161.227 with HTTP; Thu, 19 Jan 2012 02:33:34 -0800 (PST) X-Originating-IP: [66.215.95.51] In-Reply-To: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com> References: <1326967029.84665.YahooMailNeo@web121601.mail.ne1.yahoo.com> Date: Thu, 19 Jan 2012 02:33:34 -0800 Message-ID: Subject: Re: how to return whole table from Function not just the id integer column From: Samuel Gendler To: Rehan Saleem Cc: "pgsql-sql@postgresql.org" Content-Type: multipart/alternative; boundary=90e6ba6e86fcabb44904b6df1852 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201201/87 X-Sequence-Number: 36258 --90e6ba6e86fcabb44904b6df1852 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jan 19, 2012 at 1:57 AM, Rehan Saleem 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 --90e6ba6e86fcabb44904b6df1852 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Thu, Jan 19, 2012 at 1:57 AM, Rehan Salee= m <pk_rehan@yaho= o.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 necessa= ry to answer this question. =A0If, after reading that chapter and attemptin= g to solve the problem yourself, you still have no success, then please pos= t your question to the list along with your best attempt at a solution. =A0= You cannot expect to make efficient use of a sophisticated rdbms without fi= rst reading at least the most relevant sections of the documentation, and t= he mailing lists do not have enough experienced users to devote bandwidth t= o doing your work for you.


--90e6ba6e86fcabb44904b6df1852--