Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-0.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-0.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-0.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-0.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -16,10 +16,16 @@
# equal to the new sort key (average of prev_sort_key and next_sort_key);
# otherwise warn them that their form is not up-to-date
+### gilbertw - added do the calculation outside of the db. PostgreSQL encloses
+# the bind variables in ' '
+# where sort_key = (:prev_sort_key + :next_sort_key)/2
+set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
+
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2"]
+where sort_key = :sort_key"]
+
if { $n_conflicts > 0 } {
ad_return_complaint 1 "
The page you came from appears to be out-of-date;
perhaps someone has changed the categories since you last reloaded the page.
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-0.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-0.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-0.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-0.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -5,7 +5,7 @@
select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2
+where sort_key = :sort_key
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-2-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-2-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-2-oracle.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-2-oracle.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -8,7 +8,7 @@
insert into ec_categories
(category_id, category_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
-(:category_id, :category_name, (:prev_sort_key + :next_sort_key)/2, sysdate, :user_id, :peeraddr)
+(:category_id, :category_name, :sort_key, sysdate, :user_id, :peeraddr)
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-2-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-2-postgresql.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-2-postgresql.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -8,7 +8,7 @@
insert into ec_categories
(category_id, category_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
-(:category_id, :category_name, (:prev_sort_key + :next_sort_key)/2, current_timestamp, :user_id, :peeraddr)
+(:category_id, :category_name, :sort_key, current_timestamp, :user_id, :peeraddr)
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-2.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-2.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-2.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -43,9 +43,14 @@
}
# now make sure there's no category with that sort key already
+### gilbertw - added do the calculation outside of the db. PostgreSQL encloses
+# the bind variables in ' '
+# where sort_key = (:prev_sort_key + :next_sort_key)/2
+set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
+
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2"]
+where sort_key = :sort_key"]
if { $n_conflicts > 0 } {
ad_return_complaint 1 "The category page appears to be out-of-date;
@@ -59,6 +64,6 @@
db_dml insert_into_ec_categories "insert into ec_categories
(category_id, category_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
-(:category_id, :category_name, (:prev_sort_key + :next_sort_key)/2, sysdate, :user_id, :peeraddr)"
+(:category_id, :category_name, :sort_key, sysdate, :user_id, :peeraddr)"
db_release_unused_handles
ad_returnredirect "index"
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add-2.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add-2.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add-2.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -13,7 +13,7 @@
select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2
+where sort_key = :sort_key
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -18,9 +18,14 @@
# equal to the new sort key (average of prev_sort_key and next_sort_key);
# otherwise warn them that their form is not up-to-date
+### gilbertw - added do the calculation outside of the db. PostgreSQL encloses
+# the bind variables in ' '
+# where sort_key = (:prev_sort_key + :next_sort_key)/2
+set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
+
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2"]
+where sort_key = :sort_key"]
if { $n_conflicts > 0 } {
ad_return_complaint 1 "The category page appears to be out-of-date;
Index: openacs-4/packages/ecommerce/www/admin/cat/category-add.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/category-add.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/category-add.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/category-add.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -5,7 +5,7 @@
select count(*)
from ec_categories
-where sort_key = (:prev_sort_key + :next_sort_key)/2
+where sort_key = :sort_key
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -24,11 +24,15 @@
# (average of prev_sort_key and next_sort_key);
# otherwise warn them that their form is not up-to-date
+### gilbertw - added do the calculation outside of the db. PostgreSQL encloses
+# the bind variables in ' '
+# where sort_key = (:prev_sort_key + :next_sort_key)/2
+set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2"]
+and sort_key = :sort_key"]
if { $n_conflicts > 0 } {
ad_return_complaint 1 "The page you came from appears to be out-of-date;
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-0.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -6,7 +6,7 @@
select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2
+and sort_key = :sort_key
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-oracle.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-oracle.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -8,7 +8,7 @@
insert into ec_subcategories
(category_id, subcategory_id, subcategory_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
- (:category_id, :subcategory_id, :subcategory_name, (:prev_sort_key + :next_sort_key)/2, sysdate, :user_id, :address)
+ (:category_id, :subcategory_id, :subcategory_name, :sort_key, sysdate, :user_id, :address)
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-postgresql.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2-postgresql.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -8,7 +8,7 @@
insert into ec_subcategories
(category_id, subcategory_id, subcategory_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
- (:category_id, :subcategory_id, :subcategory_name, (:prev_sort_key + :next_sort_key)/2, current_timestamp, :user_id, :address)
+ (:category_id, :subcategory_id, :subcategory_name, :sort_key, current_timestamp, :user_id, :address)
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -50,10 +50,15 @@
# now make sure there's no subcategory in this category with that sort key already
db_transaction {
+ ### gilbertw - added do the calculation outside of the db.
+ # PostgreSQL encloses the bind variables in ' '
+ # where sort_key = (:prev_sort_key + :next_sort_key)/2
+ set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
+
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2"]
+and sort_key = :sort_key"]
if { $n_conflicts > 0 } {
ad_return_complaint 1 "The $category_name page appears to be out-of-date;
perhaps someone has changed the subcategories since you last reloaded the page.
@@ -65,7 +70,7 @@
db_dml ec_subcat_insert "insert into ec_subcategories
(category_id, subcategory_id, subcategory_name, sort_key, last_modified, last_modifying_user, modified_ip_address)
values
- (:category_id, :subcategory_id, :subcategory_name, (:prev_sort_key + :next_sort_key)/2, sysdate, :user_id, :address)"
+ (:category_id, :subcategory_id, :subcategory_name, :sort_key, sysdate, :user_id, :address)"
} on_error {
db_release_unused_handles
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add-2.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -14,7 +14,7 @@
select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2
+and sort_key = :sort_key
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.tcl 20 Apr 2001 20:51:13 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.tcl 17 Jul 2001 23:59:03 -0000 1.2
@@ -27,11 +27,15 @@
# (average of prev_sort_key and next_sort_key);
# otherwise warn them that their form is not up-to-date
+### gilbertw - added do the calculation outside of the db. PostgreSQL encloses
+# the bind variables in ' '
+# where sort_key = (:prev_sort_key + :next_sort_key)/2
+set sort_key [expr ($prev_sort_key + $next_sort_key)/2]
set n_conflicts [db_string get_n_conflicts "select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2"]
+and sort_key = :sort_key"]
if { $n_conflicts > 0 } {
ad_return_complaint 1 "The $category_name page appears to be out-of-date;
Index: openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.xql 10 Jul 2001 20:33:53 -0000 1.1
+++ openacs-4/packages/ecommerce/www/admin/cat/subcategory-add.xql 17 Jul 2001 23:59:03 -0000 1.2
@@ -6,7 +6,7 @@
select count(*)
from ec_subcategories
where category_id=:category_id
-and sort_key = (:prev_sort_key + :next_sort_key)/2
+and sort_key = :sort_key