From: Ivan Kohler Date: Wed, 28 Jan 2015 10:26:47 +0000 (-0800) Subject: optimize cust_pay__otaker_ivan upgrade fix (pretty obsolete at this point?) X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=f4b7701c4c1e574ebe29e05db694d131d2799b35 optimize cust_pay__otaker_ivan upgrade fix (pretty obsolete at this point?) --- diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 87fad02f1..df567a5c1 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -942,10 +942,11 @@ sub _upgrade_data { #class method #not the most efficient, but hey, it only has to run once - my $where = "WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) ". - " AND usernum IS NULL ". - " AND 0 < ( SELECT COUNT(*) FROM cust_main ". - " WHERE cust_main.custnum = cust_pay.custnum ) "; + my $where = " WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) + AND usernum IS NULL + AND EXISTS ( SELECT 1 FROM cust_main + WHERE cust_main.custnum = cust_pay.custnum ) + "; my $count_sql = "SELECT COUNT(*) FROM cust_pay $where";