From: Tim Landscheidt <tim@tim-landscheidt.de>
To: pgsql-sql@postgresql.org
Subject: Re: what does this do
Date: Thu, 10 Jun 2010 14:56:45 +0000
Message-ID: <m3eigfc4wi.fsf@passepartout.tim-landscheidt.de> (raw)
References: <201006100222.03196.johnf@jfcomputer.com>
<m3y6encfzw.fsf@passepartout.tim-landscheidt.de>
<AANLkTim52D_0yvXC9Y9eAJjIGoBm1WaIopfFjobz55R2@mail.gmail.com>
Richard Broersma <richard.broersma@gmail.com> wrote:
>>> I have a piece of python code that excutes a SQL statement:
>>> apitempCur.execute("select * from jfcs_balancedue('%s') f(enrolleeid varchar,
>>> course_cost decimal, paid_amt decimal)" % (enrollIds,));
>>> The "enrollids" is a list of primary keys and the "jfcs_balancedue" is a user
>>> defined function. What I don't understand is the "f(enrolleeid
>>> varchar, ...)" I have no idea what it's for? Would some kind soul educate
>>> me.
>> You can omit the "AS" from "table_name AS alias
>> (column_alias, ...)", but AFAIK PostgreSQL doesn't support
>> specifying a data type for each column. Which DBMS is this
>> code used for?
> Well, it doesn't support data-types in the alias declaration for all
> set returning relations with the exception of a set returning function
> (i.e. store procedure). The from clause has a give-away that this is
> a set returning function: "jfcs_balancedue('%s')" since it has a
> parameter.
> Notice the function name section taken from the from clause:
> http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FROM
Another lesson learned :-). But it applies strictly to *re-
cord* returning functions, doesn't it? Because I had tested
generate_series() prior to my reply:
| tim=# SELECT ID FROM generate_series(1, 2) AS G(ID);
| id
| ----
| 1
| 2
| (2 Zeilen)
| tim=# SELECT ID FROM generate_series(1, 2) AS G(ID INT);
| ERROR: a column definition list is only allowed for functions returning "record"
| ZEILE 1: SELECT ID FROM generate_series(1, 2) AS G(ID INT);
| ^
| tim=#
but didn't follow the (now obvious) clue ...
Tim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tim@tim-landscheidt.de
Subject: Re: what does this do
In-Reply-To: <m3eigfc4wi.fsf@passepartout.tim-landscheidt.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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