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.2 -r1.20.8.3
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql	7 Aug 2017 13:34:17 -0000	1.20.8.2
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql	7 Aug 2017 21:11:23 -0000	1.20.8.3
@@ -228,10 +228,10 @@
       </querytext>
 </fullquery>
 
-<fullquery name="apm_dependency_provided_p.get_service_versions">
+<fullquery name="apm_dependency_provided_p.apm_dependency_check">      
       <querytext>
       
-	select service_version
+	select apm_package_version.version_name_greater(service_version, :dependency_version) as version_p
 	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,6 +242,12 @@
       </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.2 -r1.20.8.3
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	7 Aug 2017 13:34:17 -0000	1.20.8.2
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql	7 Aug 2017 21:11:23 -0000	1.20.8.3
@@ -169,10 +169,10 @@
       </querytext>
 </fullquery>
 
- <fullquery name="apm_dependency_provided_p.get_service_versions">
+ <fullquery name="apm_dependency_provided_p.apm_dependency_check">      
       <querytext>
       
-	select service_version
+	select apm_package_version__version_name_greater(service_version, :dependency_version) as version_p
 	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,6 +183,12 @@
       </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.26 -r1.109.2.27
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl	7 Aug 2017 13:34:17 -0000	1.109.2.26
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl	7 Aug 2017 21:11:23 -0000	1.109.2.27
@@ -85,12 +85,11 @@
     set old_version_p 0
     set found_p 0
     ns_log Debug "apm_dependency_provided_p: Scanning for $dependency_uri version $dependency_version"
-    foreach service_version [db_list get_service_versions {}] {
-        set version_p [expr {[apm_version_names_compare $service_version $dependency_version] >= 0}]
-        if { $version_p } {
+    db_foreach apm_dependency_check {} {
+        if { $version_p >= 0 } {
             ns_log Debug "apm_dependency_provided_p: Dependency satisfied by previously installed package"
             set found_p 1
-        } else {
+        } elseif { $version_p == -1 } {
             set old_version_p 1
         }
     }
@@ -106,8 +105,9 @@
             if {$dependency_uri eq [lindex $prov 0]} {
 
                 set provided_version [lindex $prov 1]
-                set provided_p [expr {[apm_version_names_compare $provided_version $dependency_version] >= 0}]
-                if { $provided_p } {
+                set provided_p [db_string version_greater_p {}]
+
+                if { $provided_p >= 0 } {
                     ns_log Debug "apm_dependency_provided_p: Dependency satisfied in list of provisions."
                     return 1
                 } else {