Re: crosstab function

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Martin Mueller <martinmueller(at)northwestern(dot)edu>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: crosstab function
Date: 2019-02-27 02:07:49
Message-ID: 875zt6f0pp.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Martin" == Martin Mueller <martinmueller(at)northwestern(dot)edu> writes:

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 ‘import modules’ yields nothing.

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’t exist. I tried

Martin> CREATE EXTENSION IF NOT EXISTS tablefunc;

Martin> but it did nothing. It doesn’t 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.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin Mueller 2019-02-27 02:10:59 Re: crosstab function
Previous Message Adrian Klaver 2019-02-27 02:04:17 Re: crosstab function