Re: Multi-row update w. plpgsql function

From: Daniel Hertz <danielhertz(at)shaw(dot)ca>
To: "postgreSQL (SQL)" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Multi-row update w. plpgsql function
Date: 2005-12-15 00:46:12
Message-ID: 43A0BCD4.7050809@shaw.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)osl(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Neil Dugan 2005-12-15 01:08:16 Re: Extract date from week
Previous Message Bruno Wolff III 2005-12-14 19:13:57 Re: # of 5 minute intervals in period of time ...