pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Hertz <danielhertz@shaw.ca>
To: postgreSQL (SQL) <pgsql-sql@postgresql.org>
Subject: Re: Multi-row update w. plpgsql function
Date: Wed, 14 Dec 2005 17:46:12 -0700
Message-ID: <43A0BCD4.7050809@shaw.ca> (raw)
In-Reply-To: <1319fbba0512131804v55dd3f24h3cddf5b10ef70a0c@mail.gmail.com>
References: <144D12D7DD4EC04F99241498BB4EEDCC18FFE2@nelson.osl.com>
	<1319fbba0512131804v55dd3f24h3cddf5b10ef70a0c@mail.gmail.com>

Aaron Koning wrote:
> Owen makes a good point. Check that you are using the [] in the HTML input
> variable for the checkboxes. Like:
>
> <input type="checkbox" name="approved[]" value="1" /> 1 <br/>
> <input type="checkbox" name="approved[]" value="2" /> 2 <br/>
> <input type="checkbox" name="approved[]" value="3" /> 3 <br/>
> <input type="checkbox" name="approved[]" value="4" /> 4 <br/>
>
> Aaron
>
> On 12/13/05, Owen Jacobson <ojacobson@osl.com> wr
>> I'm not familiar with Cocoon, but I'd expect that to return only the first
>> of the "approved" values from the HTTP request.  If you add logging to the
>> stored function (RAISE NOTICE 'approved: %', approved; near the start of the
>> function, for instance) and tell PostgreSQL to store the logs, you can see
>> what values your function is actually being called with.
>>
>> What you really want to do is begin a transaction, loop over all the
>> values of approved present in the form data and call (the rewritten version
>> of) update_messages for each one, then commit the transaction.
>>
>> -Owen

Thank you all, so much, for taking the time to help me out. Especially 
as a beginner, where coding IS rocket science.

On the general board, Aaron mentioned:

UPDATE message_table SET status = 'A' WHERE mid IN (1,2,3);

which seems very succinct and economical. I'm gonna have a go at parsing the query string using XSLT, substituting the variable for:

UPDATE message_table SET status = 'A' WHERE mid IN ($query_values_here);

Again, thanks for the help,

Daniel





view thread (6+ messages)

Message-ID: <43A0BCD4.7050809@shaw.ca>
Permalink:  ../43A0BCD4.7050809@shaw.ca/
Also on:    postgresql.org/message-id/43A0BCD4.7050809@shaw.ca

 · 

reply

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: danielhertz@shaw.ca
  Subject: Re: Multi-row update w. plpgsql function
  In-Reply-To: <43A0BCD4.7050809@shaw.ca>

* 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