[GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Hi list, First steps in trigger functions and PL/pgSQL so please bear with me... How can one detect changes to certain fields in before update trigger functions? IF (NEW. != OLD.) THEN ... doesn't work, so obviously my understanding of the values of the varriables NEW and OLD in before update

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Quoth Adrian Klaver <[EMAIL PROTECTED]>: > On Monday 01 December 2008 7:18:51 am Sebastian Tennant wrote: >> I had thought that OLD holds the record as it was before the update, >> and that NEW holds the record as it is since the update (but before >> the update h

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Quoth "Richard Broersma" <[EMAIL PROTECTED]>: > On Mon, Dec 1, 2008 at 7:18 AM, Sebastian Tennant > <[EMAIL PROTECTED]> wrote: > >> IF (NEW. != OLD.) THEN ... > > The != operator doesn't work the way you might think when nulls are > thrown int

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Quoth "Richard Broersma" <[EMAIL PROTECTED]>: > On Mon, Dec 1, 2008 at 8:35 AM, Sebastian Tennant > <[EMAIL PROTECTED]> wrote: >>>> IF (NEW. != OLD.) THEN ... >>> >>> IF( NEW.* IS DISTINCT FROM OLD.* ) THEN ... >>> >> I som

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Quoth Tom Lane <[EMAIL PROTECTED]>: > Sebastian Tennant <[EMAIL PROTECTED]> writes: >> I sometimes think this kind of gotcha is purposely buried, or not >> addressed at all, in order to force users to read the manual. > > Where exactly do you think we should docume

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-01 Thread Sebastian Tennant
Quoth Alvaro Herrera <[EMAIL PROTECTED]>: > Sebastian Tennant wrote: > >> P.S. Emacs users of PostgreSQL might like to know that there's a >> texinfo version of the manual (version 8.3.3) available for >> download from here: >> >>

Re: [GENERAL] Detecting changes to certain fields in 'before update' trigger functions

2008-12-02 Thread Sebastian Tennant
Quoth Alvaro Herrera <[EMAIL PROTECTED]>: > Sebastian Tennant wrote: >> Quoth Alvaro Herrera <[EMAIL PROTECTED]>: >> > Sebastian Tennant wrote: >> > >> >> P.S. Emacs users of PostgreSQL might like to know that there's a >> >&g

[GENERAL] Unique constaint violated without being violated

2008-12-06 Thread Sebastian Tennant
Hi all, Here's an odd one: itidb=> \d joblist; Table "public.joblist" Column | Type | Modifiers ---+--+--- full_name | character varying(64)| not null email_address | charact

Re: [GENERAL] Resp.: Automatic insert statement generator?

2008-12-06 Thread Sebastian Tennant
Hi Osvaldo, Your list_fields function looked interesting to me so I tried it out and it only worked for one of the five or so tables in the database I was connected to at the time. More concerning is the fact that I can't seem to drop it. I'm told it doesn't exist, and then I use it to prove (to

Re: [GENERAL] Unique constaint violated without being violated

2008-12-06 Thread Sebastian Tennant
Quoth "Merlin Moncure" <[EMAIL PROTECTED]>: > It looks to me like you are setting the whole table to the same > address in the update statement (no where clause)...so of course you'd > get the error. Maybe you want to do an insert statement? > > merlin Doh! Thanks Merlin. I'm so glad it's just

Re: [GENERAL] Resp.: Automatic insert statement generator?

2008-12-06 Thread Sebastian Tennant
Quoth Raymond O'Donnell <[EMAIL PROTECTED]>: > On 06/12/2008 16:02, Sebastian Tennant wrote: >> Here's it working: >> >> itidb=> select list_fields('joblist'); > > > >> Here's me trying to drop it, only to be told it

[GENERAL] Ordering returned rows according to a list

2008-12-22 Thread Sebastian Tennant
Hi all, I'd like to make a single query that returns a number of rows using a 'WHERE id IN ()' condition, but I'd like the rows to be returned in the order in which the ids are given in the list. Is this possible? Sebastian -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)

Re: [GENERAL] Ordering returned rows according to a list

2008-12-22 Thread Sebastian Tennant
Quoth "Adam Rich" : >> I'd like to make a single query that returns a number of rows using a >> 'WHERE id IN ()' condition, but I'd like the rows to be >> returned in the order in which the ids are given in the list. >> > Depending on how many IDs you have in your list, you can accomplish this > wi

[GENERAL] Building the PostgreSQL manual in Info format on Debian Lenny

2009-01-25 Thread Sebastian Tennant
Hello, Here's a step-by-step guide to building the PostgreSQL manual in Info format on a Debian Lenny box: First of all, you may made need to install a few extra packages: $ sudo apt-get install bzip2 docbook-dsssl docbook2x opensp Next, download the PostgreSQL source (using apt), unpack it a

[GENERAL] Recovery mode

2009-01-29 Thread Sebastian Tennant
Hi there, Just noticed this in my webapp logs: ERROR: FATAL: the database system is in recovery mode Only one instance, so I'm not too concerned, but why, how often, how long for, etc. Am I negelecting to do some important database maintenace? Could it be related to the backup cron performs

Re: [GENERAL] running postgres

2009-02-05 Thread Sebastian Tennant
Quoth Kusuma Pabba : > /usr/local/pgsql/bin/psql test > test=# > sudo su postgres -c psql template1 > template=# > why is the path different in both cases? Type: $ which psql and $ sudo which psql The answer is the same, yes? $ /usr/local/pgsql/bin/psql test |___|

[GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-18 Thread Sebastian Tennant
Hi all, A school wants to offer a number of short courses on a number of different dates. Students apply online for a single course at a time and choose one or more dates (from a list) which would suit them. Once the application period is over which course is taught when is decided soley on the b

Re: [GENERAL] Best database model for canvassing (and analysing) opinion

2009-08-20 Thread Sebastian Tennant
Quoth Sam Mason : [...] > The only table that's really needed to solve your original problem would > be the last one, but the others provide all the checks that the data > is actually going in correctly and may or may not be useful depending > on your problem. The main thing to notice is lots of

[GENERAL] Help needed creating a view

2012-01-26 Thread Sebastian Tennant
Hi list, Given an 'applications' table for a static set of courses:: user_id (integer) course_name (text) completed (boolean) how best should I go about creating an 'alumni' view with columns: user_id (integer) maths (boolean) english (boolean) . . . . . . w

Re: [GENERAL] Help needed creating a view

2012-01-27 Thread Sebastian Tennant
Quoth "David Johnston" : > A) SELECT user_id, CASE WHEN course_name = 'Maths' THEN completed ELSE false > END math_cmp, CASE WHEN course_name = 'English' THEN completed ELSE false > END AS english_cmp FROM applications > a) Expand to multiple columns and store either the default "false" or the