Forum OpenACS Q&A: Response to update returns 1, but no changes have been made

Hi Jerry -

This is happening on two servers:

  1. my development server, running Postgres 7.0.3, RedHat 7.1
  2. soon-to-be production server, hosted at, running Postgres 7.1.3, RedHat 6.2

The datamodel:

insert statements...

set db [ns_db gethandle]

set sql_query "select product_type_id from wpp_product_type 
where product_type = '$product_type'"

set selection [ns_db 1row $db $sql_query]
set product_type_id [ns_set value $selection 0]

ns_db dml $db "begin"
ns_db dml $db "lock table wpp_product_question in exclusive mode"

set selection [ns_db 1row $db "select max(product_question_id)+1 
from wpp_product_question"]

set question_id [ns_set value $selection 0]
if [empty_string_p $question_id] {
        set question_id 1

set selection [ns_db 1row $db "select max(sort_order)+1 
from wpp_product_question 
where product_type_id = $product_type_id"]

set sort_order [ns_set value $selection 0]
if [empty_string_p $sort_order] {
        set sort_order 1

ns_db dml $db "insert into wpp_product_question (product_question_id,
product_type_id, product_question, sort_order, last_modified,
last_modifying_user, modified_ip_address)
    values ('$question_id', '$product_type_id', 
'[DoubleApos question]', '$sort_order',sysdate(), '$user_id', 
'[DoubleApos [ns_conn peeraddr]]')"

ns_db dml $db "end"

update statement...

set db [ns_db gethandle]

set sql_update "update wpp_product_question 
set product_question = '[DoubleApos $question]', 
editor_notes = '[DoubleApos $q_notes]', approved_p = '$approved_p',
last_modified = sysdate(), last_modifying_user = '$user_id',
modified_ip_address = '[DoubleApos [ns_conn peeraddr]]'
where product_question_id = '$q_id'"

ns_db dml $db "begin"
ns_db dml $db "$sql_update"
ns_db dml $db "end"

Here are some possibly relevant usenet postings: