Advisable to move SQL from PHP to functions?

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Advisable to move SQL from PHP to functions?
Date: 2003-05-13 17:19:40
Message-ID: 20030513171940.GA6271@campbell-lange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm about to embark on a new project using a fairly extensive set of sql
queries, many of them using SQL/Postgres features like unions, left
outer joins etc. I'd like to know if it is advisable to write many of
the queries as views or functions in plpgsql rather than having a 1000
line file to parse in php.

I haven't been using functions and triggers much (in fact the only
function/trigger pair I use updates a timestamp when tables are
updated). Is it possible to make a function to receive values and then
make records in several tables with these values? Can an insert return
the oid or serial number resulting from the insert? Can a "select" cause
values to be updated on the selected rows (eg a "seen" field).

If it is advisable to work in postgres I'd be grateful to know if there
is a sensible system for editing triggers and functions on a live
database. At present I can see my triggers in pg_trigger but can't edit
them; \df doesn't seem to list my functions at all. I'm looking for a
technique compatible with my technique of using readline (in vi mode) on
the psql prompt; \e takes me to vim.

--
Rory Campbell-Lange
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2003-05-13 17:54:23 Re: Advisable to move SQL from PHP to functions?
Previous Message sandeep bantia 2003-05-13 13:52:01 Query regarding Insert Statement!!!!