Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql,v
diff -u -r1.20.8.1 -r1.20.8.2
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql	2 Jan 2016 11:22:35 -0000	1.20.8.1
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql	7 Aug 2017 13:34:17 -0000	1.20.8.2
@@ -228,10 +228,10 @@
       </querytext>
 </fullquery>
 
-<fullquery name="apm_dependency_provided_p.apm_dependency_check">      
+<fullquery name="apm_dependency_provided_p.get_service_versions">
       <querytext>
       
-	select apm_package_version.version_name_greater(service_version, :dependency_version) as version_p
+	select service_version
 	from apm_package_dependencies d, apm_package_types a, apm_package_versions v
 	where d.dependency_type = 'provides'
 	and d.version_id = v.version_id
@@ -242,12 +242,6 @@
       </querytext>
 </fullquery>
 
- <fullquery name="apm_dependency_provided_p.version_greater_p">      
-      <querytext>
-        select apm_package_version.version_name_greater(:provided_version, :dependency_version) from dual
-      </querytext>
-</fullquery>
-
 <fullquery name="apm_copy_param_to_descendents.param_exists">      
   <querytext>
     begin
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.20.8.1 -r1.20.8.2
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	2 Jan 2016 11:22:35 -0000	1.20.8.1
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	7 Aug 2017 13:34:17 -0000	1.20.8.2
@@ -169,10 +169,10 @@
       </querytext>
 </fullquery>
 
- <fullquery name="apm_dependency_provided_p.apm_dependency_check">      
+ <fullquery name="apm_dependency_provided_p.get_service_versions">
       <querytext>
       
-	select apm_package_version__version_name_greater(service_version, :dependency_version) as version_p
+	select service_version
 	from apm_package_dependencies d, apm_package_types a, apm_package_versions v
 	where d.dependency_type = 'provides'
 	and d.version_id = v.version_id
@@ -183,12 +183,6 @@
       </querytext>
 </fullquery>
 
- <fullquery name="apm_dependency_provided_p.version_greater_p">      
-      <querytext>
-        select apm_package_version__version_name_greater(:provided_version, :dependency_version)
-      </querytext>
-</fullquery>
-
 <fullquery name="apm_copy_param_to_descendents.param_exists">      
   <querytext>
     select apm__parameter_p(:descendent_package_key, :parameter_name);
Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl,v
diff -u -r1.109.2.25 -r1.109.2.26
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl	1 Aug 2017 10:17:24 -0000	1.109.2.25
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl	7 Aug 2017 13:34:17 -0000	1.109.2.26
@@ -85,11 +85,12 @@
     set old_version_p 0
     set found_p 0
     ns_log Debug "apm_dependency_provided_p: Scanning for $dependency_uri version $dependency_version"
-    db_foreach apm_dependency_check {} {
-        if { $version_p >= 0 } {
+    foreach service_version [db_list get_service_versions {}] {
+        set version_p [expr {[apm_version_names_compare $service_version $dependency_version] >= 0}]
+        if { $version_p } {
             ns_log Debug "apm_dependency_provided_p: Dependency satisfied by previously installed package"
             set found_p 1
-        } elseif { $version_p == -1 } {
+        } else {
             set old_version_p 1
         }
     }
@@ -105,9 +106,8 @@
             if {$dependency_uri eq [lindex $prov 0]} {
 
                 set provided_version [lindex $prov 1]
-                set provided_p [db_string version_greater_p {}]
-
-                if { $provided_p >= 0 } {
+                set provided_p [expr {[apm_version_names_compare $provided_version $dependency_version] >= 0}]
+                if { $provided_p } {
                     ns_log Debug "apm_dependency_provided_p: Dependency satisfied in list of provisions."
                     return 1
                 } else {