After Save Record triggered flow is not working for bulk update in account object - salesforce-lightning

We have got a talk to convert workflow into flow, So while doing that there is a workflow which has two action one is field update and other is send Out bound message for the below condition.
AND( (Magento_ID__c <> null && !BEGINS(Magento_ID__c,'9')), RecordType.DeveloperName = 'Lorentz_Customer', OR( ISCHANGED( BillingCity ) || ISCHANGED( BillingCountry ) || ISCHANGED( BillingStreet ) || ISCHANGED( BillingState ) || ISCHANGED( BillingPostalCode )|| ISCHANGED( ShippingCity ) || ISCHANGED( ShippingCountry) || ISCHANGED( ShippingStreet ) || ISCHANGED( ShippingState ) || ISCHANGED( ShippingPostalCode ) || ISCHANGED(PersonEmail) || ISCHANGED( Birthday__pc ) || ISCHANGED(LastName) || ISCHANGED( FirstName) || ISCHANGED( Salutation) ) )
So i have created before save and after save flow. Both working fine for few number of data. but if i upload large amount of data (5000) with batch size of 200 then its failing because of after save flow. Is there any way where we can bulkify the after save flow?

Related

Finding the common element between two result sets in PostgreSQL

I have created the following tables.
CREATE TABLE table1 (
idx SERIAL PRIMARY KEY,
refs_person TEXT[],
id_gps TEXT
);
CREATE TABLE table2 (
idx SERIAL PRIMARY KEY,
id_person TEXT,
city TEXT,
location INTEGER
);
I populated them with this information.
Table 1
idx || refs_person || id_gps
1 || {id_per_234, id_per_456} || gps_20
2 || {id_per_568} || gps_23
3 || {id_per_345, id_per_334, id_per_340} || gps_45
Table 2
idx || id_person || city || location
1 || id_per_234 || Paris || 20
2 || id_per_999 || York || 20
3 || id_per_213 || Paris || 20
4 || id_per_334 || Paris || 32
If I try to find out id_person in Paris with location 20.
select id_person from table2 where city = 'Paris' and location = '20';
id_per_234
id_per_213
Then, if I try to find out refs_person with id_gps 20 for table 1
select refs_person from table1 where id_gps = '20';
{id_per_234, id_per_456}
I'm having an issue relating to finding the common element between this two results.
For the this example, I want to get id_per_234.
I have tried using intersect statement without any success.
Any ideas?
You need to unnest the array, best using a LATERAL join, before you can INTERSECT the results:
SELECT rp.rp
FROM table1
CROSS JOIN LATERAL unnest(table1.refs_person) AS rp(rp)
WHERE id_gps = 'gps_20'
INTERSECT
SELECT id_person
FROM table2
WHERE city = 'Paris' AND location = 20;
rp
------------
id_per_234
(1 row)

Need help combining the results of two select statements

My first select statements is:
SELECT cRefNum, cName, cProgram || '-' || cCode || '-' || cSection as CourseDesc, cTimeStart, cTimeEnd, cDay, ct.cCampus, cBuildingSection || cRoom AS Room, cSchedType
from coursedetails cd inner join coursetimes ct
using (cRefNum)
where cRefNum = 3816;
Which results in:
My second select statements is:
select cRefNum, LISTAGG(fname|| ' ' || lname, ', ') within group (order by cRefNum) as Teachers
from teachers
where cRefNum = 3816
group by cRefNum;
Which results in:
What I'm trying to achieve is:
select a.cRefNum, cName, CourseDesc, cTimeStart, cTimeEnd, cDay, Campus, Room, cSchedType, Teachers
from
(select cRefNum, cName, cProgram || '-' || cCode || '-' || cSection as CourseDesc, cTimeStart, cTimeEnd, cDay, ct.cCampus as Campus, cBuildingSection || cRoom AS Room, cSchedType from coursedetails cd inner join coursetimes ct using (cRefNum) where cRefNum = 3816) a,
(select cRefNum, LISTAGG(fname|| ' ' || lname, ', ') within group (order by cRefNum) as Teachers from teachers where cRefNum = 3816 group by cRefNum) b
where a.cRefNum = b.cRefNum;
This fixes it, but is really long and I don't know enough to shorten it.

Extract string of dynamic length when the indicator of completion exists in multiple instances. Postgres

So if I have a varchar length string column let's call ID(samples below):
97.128.39.256.1460854333288493
25.365.49.12.13454154815132
346.45.156.354.1523425161233
I want to grab, like a left in excel, everything to the left of the 4th period. How do i create a dynamic string to find the fourth instance of a period?
I know substring is a start but not sure how to write in the dynmic length that exists
This is probably the easiest for someone else to read:
select split_part(i, '.', 1) || '.' ||
split_part(i, '.', 2) || '.' ||
split_part(i, '.', 3) || '.' ||
split_part(i, '.', 4)
from (select '97.128.39.256.1460854333288493' as i) as sub;
Or if you don't like split_part and prefer to use arrays:
select array_to_string((string_to_array(i, '.'))[1:4], '.')
from (select '97.128.39.256.1460854333288493' as i) as sub;
I think the array example is a bit harder to grasp at first glance but both work.
Updated answer based on revised question to also convert the Unix timestamp to a Greenplum timestamp:
select 'epoch'::timestamp + '1 second'::interval *
(split_part(i, '.', 5)::numeric/1000000) as event_time,
array_to_string((string_to_array(i, '.'))[1:4], '.') as ip_address
from (
select '97.128.39.256.1460854333288493' as i
) as sub;
You could also try this:
mydb=> select regexp_replace('97.128.39.256.1460854333288493', E'^((?:\\d+\\.){3}\\d+).+$', E'\\1');
regexp_replace
----------------
97.128.39.256
(1 row)
Time: 0.634 ms
with t (s) as ( values
('97.128.39.256.1460854333288493'),
('25.365.49.12.13454154815132'),
('346.45.156.354.1523425161233')
)
select a[1] || '.' || a[2] || '.' || a[3] || '.' || a[4]
from (
select regexp_split_to_array(s, '\.')
from t
) t (a)
;
?column?
----------------
97.128.39.256
25.365.49.12
346.45.156.354

how t use start with -connect by nocycle in postgresql

SELECT coalesce(RPAD('IN',16,' ') || RPAD( M.CASETYPE||'/' || M.CASENUMBER || '/' || M.CASEYEAR,16, ' '),' ') as inmatter
FROM (
select level as LEV, l1.LINKCASECCIN as CCI ,l1.linkcategorycode as lcode
from hclive.LINKEDMATTERS l1
start with l1.MAINCASECCIN ='001003201400100' and l1.linkcategorycode='I'
connect by nocycle prior l1.LINKCASECCIN = l1.MAINCASECCIN and l1.linkcategorycode = 'I'
) s1,
hclive.MAIN M
where M.CCIN=CCI
connect by is done with a recursive common table expression in Postgres.
with recursive tree as (
select 1 as level, l1.linkcaseccin as cci, l1.linkcategorycode as lcode
from hclive.linkedmatters l1
where l1.maincaseccin ='001003201400100'
and l1.linkcategorycode='I'
union all
select p.level + 1, c1.linkcaseccin as cci, c1.linkcategorycode as lcode
from hclive.linkedmatters c1
join tree p on p.maincaseccin = c1.linkcaseccin
where c1.linkcategorycode='I'
)
select coalesce(rpad('IN',16,' ') || rpad( m.casetype||'/' || m.casenumber || '/' || m.caseyear,16, ' '),' ') as inmatter
from tree t
join hclive.main M on m.ccin = t.cci;
The level column does not seem to be necessary as you don't use it at all in your query, but I left in there as an example to get the same information in Postgres.

openx adserver statistics tab error with postgres db version 9.x

I installed latest openX ad server(publisher server) with postgres 9.x version.
After successful installation and configuration i login and click at "Statistics" tab i see the following error.
i don't see this error when i installed openX server with mysql any quick fix ?
PEAR Error
MDB2 Error: unknown error
_doQuery: [Error message: Could not execute statement]
[Last executed query: SELECT m.clientid AS advertiser_id,d.campaignid AS placement_id,s.ad_id AS ad_id,SUM(s.impressions) AS sum_views,SUM(s.clicks) AS sum_clicks,SUM(s.revenue) AS sum_revenue, m.campaignid || IF( LENGTH(market_advertiser_id) > 0, ('_' || market_advertiser_id || ''), '') || ad_width || ' x ' || ad_height AS ad_id,( m.campaignid || IF( LENGTH(market_advertiser_id) > 0, ('_' || market_advertiser_id || ''), '') || ad_width || ' x ' || ad_height ) AS pkey FROM "ox_ext_market_stats" AS s INNER JOIN "ox_banners" AS d ON (d.bannerid=s.ad_id) INNER JOIN "ox_zones" AS z ON (z.zoneid=s.zone_id) INNER JOIN "ox_campaigns" AS m ON (m.campaignid=d.campaignid) INNER JOIN "ox_affiliates" AS p ON (p.affiliateid=z.affiliateid) INNER JOIN "ox_clients" AS a ON (a.clientid=m.clientid) WHERE s.ad_id IN (1,2) AND a.type = 1 AND s.zone_id <> 0 AND s.date_time>='2011-02-22 00:00:00' AND s.date_time<='2011-02-22 23:59:59' GROUP BY advertiser_id,placement_id,pkey]
[Native message: ERROR: column "s.ad_id" must appear in the GROUP BY clause or be used in an aggregate function at character 65]
PEAR Error
MDB2 Error: unknown error
_doQuery: [Error message: Could not execute statement]
[Last executed query: SELECT m.clientid AS advertiser_id,d.campaignid AS placement_id,s.ad_id AS ad_id,SUM(s.impressions) AS sum_views,SUM(s.clicks) AS sum_clicks,SUM(s.revenue) AS sum_revenue, m.campaignid || IF( LENGTH(market_advertiser_id) > 0, ('_' || market_advertiser_id || ''), '') || ad_width || ' x ' || ad_height AS ad_id,( m.campaignid || IF( LENGTH(market_advertiser_id) > 0, ('_' || market_advertiser_id || ''), '') || ad_width || ' x ' || ad_height ) AS pkey FROM "ox_ext_market_stats" AS s INNER JOIN "ox_banners" AS d ON (d.bannerid=s.ad_id) INNER JOIN "ox_campaigns" AS m ON (m.campaignid=d.campaignid) INNER JOIN "ox_clients" AS a ON (a.clientid=m.clientid) WHERE s.ad_id IN (1,2) AND s.zone_id = 0 AND a.type = 1 AND s.date_time>='2011-02-22 00:00:00' AND s.date_time<='2011-02-22 23:59:59' AND s.zone_id = 0 GROUP BY advertiser_id,placement_id,pkey]
[Native message: ERROR: column "s.ad_id" must appear in the GROUP BY clause or be used in an aggregate function at character 65]
Ok, i have found a solution. To fix the problem, must add this code after line 1031 in lib/max/SqlBuilder.php .
$aGroupColumns[] = "s.ad_id";