Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyodZ-0001QF-HY for pgsql-general@arkaria.postgresql.org; Wed, 27 Feb 2019 02:07:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyodY-0007SC-BD for pgsql-general@arkaria.postgresql.org; Wed, 27 Feb 2019 02:07:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyodX-0007S4-W3 for pgsql-general@lists.postgresql.org; Wed, 27 Feb 2019 02:07:56 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyodV-0005NK-Ij for pgsql-general@postgresql.org; Wed, 27 Feb 2019 02:07:54 +0000 Received: from [192.168.127.1] (port=43449 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gyodS-0006hS-6N; Wed, 27 Feb 2019 02:07:50 +0000 Received: from [127.0.0.1] (port=56101 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gyodR-000EpV-HP; Wed, 27 Feb 2019 02:07:49 +0000 From: Andrew Gierth To: Martin Mueller Cc: pgsql-general Subject: Re: crosstab function In-Reply-To: <3B0E0069-18FC-476D-90A1-5201891AA52C@northwestern.edu> (Martin Mueller's message of "Wed, 27 Feb 2019 01:51:13 +0000") Message-ID: <875zt6f0pp.fsf@news-spur.riddles.org.uk> References: <3B0E0069-18FC-476D-90A1-5201891AA52C@northwestern.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Wed, 27 Feb 2019 02:07:49 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Martin" =3D=3D Martin Mueller write= s: Martin> I run Postgres 10.5. I understand that there is something Martin> called tablefunc and it includes a crosstab function. On Stack Martin> Overflow I learn that you import this function. But from where Martin> and how? The Postgres documentation is quite clear and Martin> intelligible to a retired English professor like me, but there Martin> is nothing in the Postgres documentation about how to do the Martin> import, and a search for =E2=80=98import modules=E2=80=99 yields n= othing. Martin> I tried to emulate a Stack overflow query that does what I want Martin> to do, but got an error message saying that the crosstab Martin> function doesn=E2=80=99t exist. I tried Martin> CREATE EXTENSION IF NOT EXISTS tablefunc; Martin> but it did nothing. It doesn=E2=80=99t seem to work as import Martin> statements in Python do CREATE EXTENSION causes the functions to be defined in the current database; that's the only "import" that is needed. In psql, you can do this: \df+ *.crosstab* to see what functions of that name are defined and what schema they are in (should be "public" by default). Likewise \dx lists installed extensions in the current database. Remember that you need to do the CREATE EXTENSION command actually in the database in which you want to use the functions, not in any other database. Errors about functions not existing are usually caused by a problem with the number or type of parameters, since function names aren't unique (overloaded functions are allowed). You didn't tell us the actual error you got, so we can't say exactly what the problem is there. --=20 Andrew (irc:RhodiumToad)