I have a procedure which is intended to group various invoices together and send them out.
DECLARE curs CURSOR FOR
select i.e_id, i.merc_id, o.o_id .... DECLARE CONTINUE HANDLER FOR NOT FOUND SET bDone = 1; OPEN curs; SET bDone = 0;
FETCH curs INTO invoice_id, merchant_increment_id, order_id;
IF bDone THEN
END IF; IF( invoice_id is not null ) THEN
SET vURL = concat('https://mydbrinstalldomain.com/mydbr/report.php?r=7&u1=',invoice_id,'&m=1&h=xxxx&export=pdf'); select invoice_id, merchant_increment_id, order_id;
select 'dbr.mail.attach',concat(merchant_increment_id,'.pdf'),vURL; END IF; END LOOP; select 'dbr.mail',1;
select 'firstname.lastname@example.org', '', 'Invoices', 'Email body .';
I have tested all code back and forward, I should be attaching 5 records but am only getting the latest one as an attachment. I have removed all email statements and just output the select. Am I doing something incorrect in adding multiple attachments.