Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8476DB5DBD8 for ; Mon, 15 Aug 2011 13:24:42 -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 03860-07 for ; Mon, 15 Aug 2011 16:24:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail48.e.nsc.no (mail48.e.nsc.no [193.213.115.48]) by mail.postgresql.org (Postfix) with ESMTP id 69848B5D803 for ; Mon, 15 Aug 2011 13:24:33 -0300 (ADT) Received: from balapapa.localnet (107.100.202.84.customer.cdi.no [84.202.100.107]) (authenticated bits=0) by mail48.nsc.no (8.14.4/8.14.4) with ESMTP id p7FGOVpx003130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Aug 2011 18:24:31 +0200 (MEST) From: Leif Biberg Kristensen To: pgsql-general@postgresql.org Subject: Re: Using Postgresql as application server Date: Mon, 15 Aug 2011 18:24:30 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.39-gentoo-r3; KDE/4.6.5; x86_64; ; ) References: <4E46D0D7.3090700@officenet.no> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201108151824.31013.leif@solumslekt.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/439 X-Sequence-Number: 178721 On Monday 15. August 2011 16.36.23 Merlin Moncure wrote: > Postgres is not just a database -- it's a language hosting platform if > you want to use it as such. Now, you can continue to do things as > you've always done (database 'here', code 'here', web server 'here'), > but why discourage people from trying out different things? Somebody's probably going to do it -- for no other reason why than because you can. Sometimes I'll write functions like CREATE OR REPLACE FUNCTION dpp(INTEGER) RETURNS SETOF TEXT AS $$ SELECT '

' || ss_link_expand(source_text) || '

' FROM sources WHERE parent_id=$1 ORDER BY sort_order $$ LANGUAGE SQL STABLE; for dumping thext that I'll copy and paste right into a static Web page. It's a lot easier to do this in psql than a lot of other methods that I can think of. BTW, the mentioned ss_link_expand() function will generate hyperlinks on the fly from a compact format stored in the database. The concept is explained here: I'm working with Postgres and PHP in tandem, and frequently write functions in sql or pl/pgsql that will output text directly in HTML format, mostly because I've found text transformation (particularly regexp_replace) in Postgres to be far superior to the equivalent methods of doing it in PHP. Leif