Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wianr-0004kd-2E for pgsql-general@arkaria.postgresql.org; Fri, 09 May 2014 02:44:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wianq-0007Hr-Bi for pgsql-general@arkaria.postgresql.org; Fri, 09 May 2014 02:44:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wiano-0007GH-M4 for pgsql-general@postgresql.org; Fri, 09 May 2014 02:44:48 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wianl-0004Tc-5t for pgsql-general@postgresql.org; Fri, 09 May 2014 02:44:48 +0000 Received: by mail-pa0-f47.google.com with SMTP id lf10so1203249pab.20 for ; Thu, 08 May 2014 19:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-type:thread-index:content-language; bh=CPIrIBA+QuasnMW0wODDNlV5KCQwXji9IiFx1bhFtR0=; b=Z/GT/79JbLlPIhdOx5ctahC5noPYn0K7hKL9qdREDal3JYMnTNRlegOifJ15lT7RCX m32PbcH17w5VUWmElGqwuVfDI3FmYlV+Go5ltEZ8pFfWAu81vzelWMC2BckWD/8VY86H XlX5xIndMF8nKpWTArTxf8paRYpKbNxfbbdgqexKC1g5ftBmqqeumRVfN3KNhp8gecfU yXwoAwyRSxCmXlSGHNDDPgHz51DUxwNN9KsDYxYCnJw+HrCFk1ZxQVOwmM6/iL63Bkni 0eqiVWBLUQ4BhBNvSIQlix+oPXziIaar8F5tbxuZBwKV2dt9VKGGtx2oRwDrmM8zCLLx laVg== X-Received: by 10.66.158.132 with SMTP id wu4mr15021373pab.66.1399603482473; Thu, 08 May 2014 19:44:42 -0700 (PDT) Received: from hplPC ([180.254.182.91]) by mx.google.com with ESMTPSA id yn4sm4503905pbb.95.2014.05.08.19.44.38 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 May 2014 19:44:40 -0700 (PDT) From: "Hengky Liwandouw" To: "'Sim Zacks'" , References: <000601cf682e$2dce68c0$896b3a40$@com> <1399299903660-5802456.post@n5.nabble.com> <004201cf68d4$152dc3f0$3f894bd0$@com> <1399345258676-5802601.post@n5.nabble.com> <004601cf68dc$848e8420$8dab8c60$@com> <536A19E2.70607@compulab.co.il> In-Reply-To: <536A19E2.70607@compulab.co.il> Subject: Re: Crosstab function Date: Fri, 9 May 2014 10:44:28 +0800 Message-ID: <004201cf6b30$9c48c250$d4da46f0$@com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0043_01CF6B73.AA6C0250" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac9p6GoT+EN0JD//RROKUXb9ANAg7QBR/1/w Content-Language: en-us X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org This is a multipart message in MIME format. ------=_NextPart_000_0043_01CF6B73.AA6C0250 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Thanks Sim, a very usefull information. From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sim Zacks Sent: Wednesday, May 07, 2014 7:33 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Crosstab function What I have done in the past to build a generic reporting application is to have the function write the results you want in a table and return the tablename and then have the client code call select * from that table. My standard report tablename is tblreport || userid; It gets dropped at the beginning of the function, so it is basically a temp table that doesn't interfere with any other users. Example: execute 'drop table if exists reports.tblreport' || v_userid ; execute 'drop sequence if exists reports.tblreport' || v_userid || '_id_seq; create sequence reports.tblreport' || v_userid || '_id_seq'; v_sql=' create table reports.tblreport' || v_userid || ' as '; Sim ------=_NextPart_000_0043_01CF6B73.AA6C0250 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Thanks Sim, a very usefull = information.

 

 

From: = pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sim = Zacks
Sent: Wednesday, May 07, 2014 7:33 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Crosstab function

 

What I have done in the past to build a generic = reporting application is to have the function write the results you want in a = table and return the tablename and then have the client code call select * from = that table.

My standard report tablename is tblreport || userid;
It gets dropped at the beginning of the function, so it is basically a = temp table that doesn't interfere with any other users.

Example:
    execute 'drop table if exists reports.tblreport' || = v_userid ;
    execute 'drop sequence if exists reports.tblreport' = || v_userid || '_id_seq; create sequence reports.tblreport' || v_userid || '_id_seq';
    v_sql=3D' create table reports.tblreport' || v_userid = || ' as ';

Sim

 

------=_NextPart_000_0043_01CF6B73.AA6C0250--