Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 86B54633446 for ; Thu, 10 Jun 2010 11:57:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 24483-03 for ; Thu, 10 Jun 2010 14:57:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 1759F632BA7 for ; Thu, 10 Jun 2010 11:57:07 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OMjBp-00012Z-0p for pgsql-sql@postgresql.org; Thu, 10 Jun 2010 16:57:05 +0200 Received: from d220035.adsl.hansenet.de ([80.171.220.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Jun 2010 16:57:05 +0200 Received: from tim by d220035.adsl.hansenet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Jun 2010 16:57:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org connect(): No such file or directory From: Tim Landscheidt Subject: Re: what does this do Date: Thu, 10 Jun 2010 14:56:45 +0000 Organization: Lines: 47 Message-ID: References: <201006100222.03196.johnf@jfcomputer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: d220035.adsl.hansenet.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:rPTuPILsRvgyN4BJ5+HfhD04a/I= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.51 tagged_above=-5 required=5 tests=BAYES_05=-0.5, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/42 X-Sequence-Number: 34233 Richard Broersma 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