Index: openacs-4/packages/acs-admin/acs-admin.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/acs-admin.info,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-admin/acs-admin.info	27 Apr 2001 04:06:02 -0000	1.3
+++ openacs-4/packages/acs-admin/acs-admin.info	27 Apr 2001 17:39:15 -0000	1.4
@@ -11,95 +11,151 @@
         <database>oracle</database>
         <database>postgresql</database>
     </database-support>
-        <owner url="mailto:bquinn@arsdigita.com">Bryan Quinn</owner>
+        <owner url="mailto:dhogaza@pacifier.com">Don Baccus</owner>
         <summary>Provides an interface for administering the Arsdigita Community System Installation.</summary>
-        <release-date>2001-03-06</release-date>
-        <vendor url="http://www.arsdigita.com/">ArsDigita Corporation</vendor>
+        <release-date>2001-04-27 00:00:00-07</release-date>
+        <vendor url="http://www.openacs.org/">OpenACS</vendor>
         <description format="text/html">A UI for administering the ACS system.</description>
 
         <provides url="acs-admin" version="4.1"/>
 
         <files>
             <file type="package_spec" path="acs-admin.info"/>
+            <file type="query_file" db_type="oracle" path="tcl/apm-admin-procs-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="tcl/apm-admin-procs-postgresql.xql"/>
             <file type="tcl_procs" path="tcl/apm-admin-procs.tcl"/>
+            <file type="query_file" path="tcl/apm-admin-procs.xql"/>
             <file type="content_page" path="www/apm/bulk-intall.tcl"/>
+            <file type="query_file" path="www/apm/bulk-intall.xql"/>
             <file type="content_page" path="www/apm/cvs-status.tcl"/>
+            <file type="query_file" path="www/apm/cvs-status.xql"/>
             <file type="content_page" path="www/apm/file-add-2.tcl"/>
+            <file type="query_file" path="www/apm/file-add-2.xql"/>
             <file type="content_page" path="www/apm/file-add.tcl"/>
+            <file type="query_file" path="www/apm/file-add.xql"/>
             <file type="content_page" path="www/apm/file-remove.tcl"/>
+            <file type="query_file" path="www/apm/file-remove.xql"/>
             <file type="content_page" path="www/apm/file-watch-cancel.tcl"/>
             <file type="content_page" path="www/apm/file-watch.tcl"/>
+            <file type="query_file" path="www/apm/file-watch.xql"/>
+            <file type="query_file" db_type="oracle" path="www/apm/index-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/apm/index-postgresql.xql"/>
             <file type="content_page" path="www/apm/index.tcl"/>
+            <file type="query_file" path="www/apm/index.xql"/>
             <file type="content_page" path="www/apm/package-add-2.tcl"/>
+            <file type="query_file" path="www/apm/package-add-2.xql"/>
             <file type="content_page" path="www/apm/package-add.tcl"/>
+            <file type="query_file" path="www/apm/package-add.xql"/>
             <file type="content_page" path="www/apm/package-deinstall.tcl"/>
             <file type="content_page" path="www/apm/package-delete-2.tcl"/>
+            <file type="query_file" path="www/apm/package-delete-2.xql"/>
             <file type="content_page" path="www/apm/package-delete.tcl"/>
+            <file type="query_file" path="www/apm/package-delete.xql"/>
             <file type="content_page" path="www/apm/package-load-2.tcl"/>
             <file type="content_page" path="www/apm/package-load.tcl"/>
             <file type="content_page" path="www/apm/package-scan.tcl"/>
             <file type="content_page" path="www/apm/packages-install-2.tcl"/>
             <file type="content_page" path="www/apm/packages-install-3.tcl"/>
+            <file type="query_file" path="www/apm/packages-install-3.xql"/>
             <file type="content_page" path="www/apm/packages-install-4.tcl"/>
             <file type="content_page" path="www/apm/packages-install.tcl"/>
             <file type="content_page" path="www/apm/packages/index.vuh"/>
             <file type="content_page" path="www/apm/parameter-add-2.tcl"/>
+            <file type="query_file" path="www/apm/parameter-add-2.xql"/>
             <file type="content_page" path="www/apm/parameter-add.tcl"/>
+            <file type="query_file" path="www/apm/parameter-add.xql"/>
             <file type="content_page" path="www/apm/parameter-delete.tcl"/>
             <file type="content_page" path="www/apm/parameter-edit-2.tcl"/>
             <file type="content_page" path="www/apm/parameter-edit.tcl"/>
+            <file type="query_file" path="www/apm/parameter-edit.xql"/>
+            <file type="query_file" db_type="oracle" path="www/apm/version-dependencies-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/apm/version-dependencies-postgresql.xql"/>
             <file type="content_page" path="www/apm/version-dependencies.tcl"/>
+            <file type="query_file" path="www/apm/version-dependencies.xql"/>
             <file type="content_page" path="www/apm/version-dependency-add-2.tcl"/>
+            <file type="query_file" path="www/apm/version-dependency-add-2.xql"/>
+            <file type="query_file" db_type="oracle" path="www/apm/version-dependency-add-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/apm/version-dependency-add-postgresql.xql"/>
             <file type="content_page" path="www/apm/version-dependency-add.tcl"/>
+            <file type="query_file" path="www/apm/version-dependency-add.xql"/>
             <file type="content_page" path="www/apm/version-dependency-remove.tcl"/>
             <file type="content_page" path="www/apm/version-disable.tcl"/>
             <file type="content_page" path="www/apm/version-edit-2.tcl"/>
+            <file type="query_file" path="www/apm/version-edit-2.xql"/>
             <file type="content_page" path="www/apm/version-edit.tcl"/>
+            <file type="query_file" path="www/apm/version-edit.xql"/>
             <file type="content_page" path="www/apm/version-enable.tcl"/>
             <file type="content_page" path="www/apm/version-files.tcl"/>
+            <file type="query_file" path="www/apm/version-files.xql"/>
             <file type="content_page" path="www/apm/version-fs-scan.tcl"/>
+            <file type="query_file" path="www/apm/version-fs-scan.xql"/>
             <file type="content_page" path="www/apm/version-generate-diffs.tcl"/>
+            <file type="query_file" path="www/apm/version-generate-diffs.xql"/>
             <file type="content_page" path="www/apm/version-generate-info.tcl"/>
             <file type="content_page" path="www/apm/version-generate-tarball.tcl"/>
             <file type="content_page" path="www/apm/version-parameter-values.tcl"/>
+            <file type="query_file" path="www/apm/version-parameter-values.xql"/>
             <file type="content_page" path="www/apm/version-parameters.tcl"/>
+            <file type="query_file" path="www/apm/version-parameters.xql"/>
             <file type="content_page" path="www/apm/version-reload.tcl"/>
             <file type="content_page" path="www/apm/version-tag.tcl"/>
+            <file type="query_file" path="www/apm/version-tag.xql"/>
             <file type="content_page" path="www/apm/version-upgrade.tcl"/>
+            <file type="query_file" db_type="oracle" path="www/apm/version-view-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/apm/version-view-postgresql.xql"/>
             <file type="content_page" path="www/apm/version-view.tcl"/>
+            <file type="query_file" path="www/apm/version-view.xql"/>
             <file type="content_page" path="www/apm/view-unattached-files.tcl"/>
+            <file type="query_file" path="www/apm/view-unattached-files.xql"/>
             <file type="content_page" path="www/apm/write-all-specs.tcl"/>
-            <file type="query_file" db_type="postgresql" path="www/index-postgresql.xql"/>
+            <file type="query_file" path="www/apm/write-all-specs.xql"/>
             <file type="query_file" db_type="oracle" path="www/index-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/index-postgresql.xql"/>
             <file type="content_page" path="www/index.tcl"/>
+            <file type="query_file" path="www/index.xql"/>
             <file type="content_page" path="www/test/security-test.tcl"/>
             <file type="content_page" path="www/test/signed-cookies-test-2.tcl"/>
+            <file type="query_file" path="www/test/signed-cookies-test-2.xql"/>
             <file type="content_page" path="www/test/signed-cookies-test.tcl"/>
+            <file type="query_file" db_type="oracle" path="www/tests/db-api-acceptance-test-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/tests/db-api-acceptance-test-postgresql.xql"/>
             <file type="content_page" path="www/tests/db-api-acceptance-test.tcl"/>
+            <file type="query_file" path="www/tests/db-api-acceptance-test.xql"/>
             <file type="content_page" path="www/tests/index.html"/>
             <file type="content_page" path="www/tests/page-contract-test-2.tcl"/>
             <file type="content_page" path="www/tests/page-contract-test.tcl"/>
             <file type="content_page" path="www/tests/tcl-documentation.tcl"/>
             <file type="content_page" path="www/users/become.tcl"/>
+            <file type="query_file" path="www/users/become.xql"/>
             <file type="content_page" path="www/users/complex-search.adp"/>
             <file type="content_page" path="www/users/complex-search.tcl"/>
+            <file type="query_file" path="www/users/complex-search.xql"/>
             <file type="content_page" path="www/users/index.adp"/>
             <file type="content_page" path="www/users/index.tcl"/>
+            <file type="query_file" path="www/users/index.xql"/>
+            <file type="query_file" db_type="oracle" path="www/users/member-state-change-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/users/member-state-change-postgresql.xql"/>
             <file type="content_page" path="www/users/member-state-change.adp"/>
             <file type="content_page" path="www/users/member-state-change.tcl"/>
+            <file type="query_file" path="www/users/member-state-change.xql"/>
             <file type="content_page" path="www/users/one.adp"/>
             <file type="content_page" path="www/users/one.tcl"/>
+            <file type="query_file" path="www/users/one.xql"/>
             <file type="content_page" path="www/users/registration-history.adp"/>
             <file type="content_page" path="www/users/registration-history.tcl"/>
+            <file type="query_file" path="www/users/registration-history.xql"/>
             <file type="content_page" path="www/users/search.adp"/>
             <file type="content_page" path="www/users/search.tcl"/>
+            <file type="query_file" path="www/users/search.xql"/>
             <file type="content_page" path="www/users/session-history.tcl"/>
             <file type="content_page" path="www/users/sessions-one-month.tcl"/>
             <file type="content_page" path="www/users/sessions-registered-summary.tcl"/>
             <file type="content_page" path="www/users/user-add-2.adp"/>
             <file type="content_page" path="www/users/user-add-2.tcl"/>
+            <file type="query_file" path="www/users/user-add-2.xql"/>
             <file type="content_page" path="www/users/user-add-3.adp"/>
             <file type="content_page" path="www/users/user-add-3.tcl"/>
+            <file type="query_file" path="www/users/user-add-3.xql"/>
             <file type="content_page" path="www/users/user-add.adp"/>
             <file type="content_page" path="www/users/user-add.tcl"/>
         </files>
Index: openacs-4/packages/acs-admin/tcl/apm-admin-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/tcl/Attic/apm-admin-procs-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-admin/tcl/apm-admin-procs-oracle.xql	27 Apr 2001 01:41:12 -0000	1.1
+++ openacs-4/packages/acs-admin/tcl/apm-admin-procs-oracle.xql	27 Apr 2001 17:39:15 -0000	1.2
@@ -6,14 +6,11 @@
 <fullquery name="apm_higher_version_installed_p.apm_higher_version_installed_p">      
       <querytext>
       
-		declare 
-		v_version_name varchar(4000); 
-		begin
-		select version_name into v_version_name
-		from apm_package_versions where
-		version_id = apm_package.highest_version(:package_key);
-		:1 := apm_package_version.version_name_greater(:version_name, v_version_name);
-		end;
+		select apm_package_version.version_name_greater(:version_name, highest.version_name)
+                from (select version_name 
+		      from apm_package_versions
+                      where version_id = apm_package.highest_version(:package_key)
+                     ) as highest
     
       </querytext>
 </fullquery>
Index: openacs-4/packages/acs-admin/tcl/apm-admin-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/tcl/Attic/apm-admin-procs-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-admin/tcl/apm-admin-procs-postgresql.xql	27 Apr 2001 01:41:12 -0000	1.1
+++ openacs-4/packages/acs-admin/tcl/apm-admin-procs-postgresql.xql	27 Apr 2001 17:39:15 -0000	1.2
@@ -5,15 +5,12 @@
 
 <fullquery name="apm_higher_version_installed_p.apm_higher_version_installed_p">      
       <querytext>
-      FIX ME PLSQL 
-		declare 
-		v_version_name varchar(4000); 
-		begin
-		select version_name into v_version_name
-		from apm_package_versions where
-		version_id = apm_package.highest_version(:package_key);
-		:1 := apm_package_version.version_name_greater(:version_name, v_version_name);
-		end;
+
+		select apm_package_version__version_name_greater(:version_name, highest.version_name)
+                from (select version_name
+		      from apm_package_versions
+                      where version_id = apm_package__highest_version(:package_key)
+                     ) as highest
     
       </querytext>
 </fullquery>
Index: openacs-4/packages/acs-admin/tcl/apm-admin-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/tcl/apm-admin-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-admin/tcl/apm-admin-procs.tcl	13 Mar 2001 22:59:26 -0000	1.1
+++ openacs-4/packages/acs-admin/tcl/apm-admin-procs.tcl	27 Apr 2001 17:39:15 -0000	1.2
@@ -187,15 +187,8 @@
     @param version_name The name of the currently installed version.
 } {
 
-    return [db_exec_plsql apm_higher_version_installed_p {
-		declare 
-		v_version_name varchar(4000); 
-		begin
-		select version_name into v_version_name
-		from apm_package_versions where
-		version_id = apm_package.highest_version(:package_key);
-		:1 := apm_package_version.version_name_greater(:version_name, v_version_name);
-		end;
-    }]
+    # DRB: I turned this into a simple select by rearranging the code and
+    # stuck the result into queryfiles.
+    return [db_string apm_higher_version_installed_p {}]
 }
 
Index: openacs-4/packages/acs-admin/www/apm/version-edit-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/version-edit-2.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-admin/www/apm/version-edit-2.xql	27 Apr 2001 01:41:12 -0000	1.1
+++ openacs-4/packages/acs-admin/www/apm/version-edit-2.xql	27 Apr 2001 17:39:15 -0000	1.2
@@ -13,7 +13,7 @@
 <fullquery name="old_version_name">      
       <querytext>
       
-	    select version_name old_version_name, version_uri old_version_uri 
+	    select version_name as old_version_name, version_uri as old_version_uri 
 	    from apm_package_versions
 	    where version_id = $version_id
 	
Index: openacs-4/packages/acs-admin/www/apm/version-parameters-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/Attic/version-parameters-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-admin/www/apm/version-parameters-oracle.xql	27 Apr 2001 17:39:15 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+   <fullquery name="parameter_table">
+       <querytext>
+
+            select parameter_name, nvl(description, 'No Description') description, datatype, 
+                default_value, parameter_id, nvl(section_name, 'No Section') section_name
+            from apm_parameters
+            where package_key = :package_key
+            $sql_clauses
+       </querytext>
+   </fullquery> 
+</queryset>
Index: openacs-4/packages/acs-admin/www/apm/version-parameters-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/Attic/version-parameters-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-admin/www/apm/version-parameters-postgresql.xql	27 Apr 2001 17:39:15 -0000	1.1
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+   <fullquery name="parameter_table">
+       <querytext>
+
+            select parameter_name, coalesce(description, 'No Description') as description, datatype, 
+                default_value, parameter_id, coalesce(section_name, 'No Section') as section_name
+            from apm_parameters
+            where package_key = :package_key
+            $sql_clauses
+
+       </querytext>
+   </fullquery> 
+ 
+</queryset>
Index: openacs-4/packages/acs-admin/www/apm/version-parameters.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/version-parameters.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-admin/www/apm/version-parameters.tcl	13 Mar 2001 22:59:26 -0000	1.1
+++ openacs-4/packages/acs-admin/www/apm/version-parameters.tcl	27 Apr 2001 17:39:15 -0000	1.2
@@ -25,16 +25,12 @@
 		   [list datatype "Type"] \
 		   [list description "Description" {} {<td>[ad_quotehtml $description]</td>}]]
 
-set sql "
-    select parameter_name, nvl(description, 'No Description') description, datatype, 
-    default_value, parameter_id, nvl(section_name, 'No Section') section_name
-      from apm_parameters
-     where package_key = :package_key
-"
+#DRB: sql_clauses must not contain RDBMS-specific query clauses.
+set sql_clauses ""
 
 if { [exists_and_not_null dimensional_list] } {
     lappend table_def [list section_name "Section:"]
-    append sql [ad_dimensional_sql $dimensional_list]
+    append sql_clauses [ad_dimensional_sql $dimensional_list]
 }
 
 lappend table_def [list parameter_id "Actions" no_sort \
@@ -43,7 +39,7 @@
 			  <a href=parameter-edit?[export_url_vars version_id parameter_id]>edit</a></font>\] 
 			   </td>}]
 
-append sql [ad_order_by_from_sort_spec $orderby $table_def]
+append sql_clauses [ad_order_by_from_sort_spec $orderby $table_def]
 
 doc_body_append "[apm_header [list "version-view?version_id=$version_id" "$pretty_name $version_name"] "Parameters"]
 <blockquote>
@@ -57,7 +53,7 @@
      -bind [ad_tcl_vars_to_ns_set version_id package_key] \
      -Textra_vars {version_id} \
      -Tmissing_text "No parameters registered in this section." \
-		     parameter_table $sql $table_def]
+		     parameter_table "" $table_def]
 <br><a href=parameter-add?[export_url_vars version_id]>Add a new parameter</a>
 
 </blockquote>
Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	19 Apr 2001 01:17:17 -0000	1.11
+++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	27 Apr 2001 17:39:15 -0000	1.12
@@ -2408,7 +2408,7 @@
 
 
 -- function edit
-create function apm_package_version__edit (integer,integer,varchar,varchar,varchar,varchar,varchar,timestamp,varchar,varchar,char,char)
+create function apm_package_version__edit (integer,integer,varchar,varchar,varchar,varchar,varchar,timestamp,varchar,varchar,boolean,boolean)
 returns integer as '
 declare
   edit__new_version_id         alias for $1;  -- default null  
Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql	24 Apr 2001 23:59:24 -0000	1.2
+++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql	27 Apr 2001 17:39:16 -0000	1.3
@@ -5,7 +5,6 @@
  
 <fullquery name="apm_generate_tarball.apm_tarball_insert">      
       <querytext>
-      
         update apm_package_versions
            set distribution_tarball = empty_blob(),
                distribution_uri = null,
Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql	24 Apr 2001 23:59:24 -0000	1.6
+++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql	27 Apr 2001 17:39:16 -0000	1.7
@@ -6,7 +6,8 @@
  
 <fullquery name="apm_generate_tarball.apm_tarball_insert">      
       <querytext>
-      FIX ME LOB 
+      FIX ME LOB (DRB - *all* large objects should be handled by the content
+      repository so I'm leaving this wart for now.
         update apm_package_versions
            set distribution_tarball = empty_blob(),
                distribution_uri = null,
Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	27 Apr 2001 03:04:08 -0000	1.5
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	27 Apr 2001 17:39:16 -0000	1.6
@@ -66,7 +66,7 @@
       <querytext>
 
             update apm_package_versions
-            set    installed_p = (case when version_id = :version_id then 't' else 'f' end)::boolean
+            set    installed_p = (version_id = :version_id)
             where  package_key = :package_key
         
       </querytext>
@@ -89,9 +89,9 @@
 
 	    select apm__register_application (
 		        :package_key,
-			:package_uri,
 			:pretty_name,
 			:pretty_plural,
+			:package_uri,
 			:singleton_p,
 			:spec_file_path,
 			:spec_file_mtime