MySQL Forums
Forum List  »  Stored Procedures

Rows not deleting from table
Posted by: John Noble
Date: February 25, 2019 08:00AM

Hi folks,

I have a sproc as follows....

CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_AgedDebtorsInsert`(
IN p_Year varchar(4))
BEGIN

SET @p_table := CONCAT('agedDebtors', p_Year);

/* Delete previous inserts with todays date */
SET @p_SQL := CONCAT('DELETE FROM ', @p_table, ' WHERE entryDate = ', CURDATE());
prepare stmt from @p_SQL;
execute stmt;



SET @p_SQL := CONCAT('INSERT INTO ', @p_table, ' (entryDate, accountManagerID, AOLP, balance, bankCharges, cash, CCManagerID, conversionRate, countryID, customerID, dateExported, daybook, docType, discount, DOLP, dueDate, groupID, invNum, invoiceCurrency, invoiceDate, net, netWeight, orderRef, payable, paymentStatus, paidToDate, transactionType, vat, boxes, freshFrozen, comment, accountID, dayBookNo)
SELECT curDate(), accountManagerID, AOLP, balance, bankCharges, cash, CCManagerID, conversionRate, countryID, customerID, dateExported, daybook, docType, discount, DOLP, dueDate, groupID, invNum, invoiceCurrency, invoiceDate, net, netWeight, orderRef, payable, paymentStatus, paidToDate, transactionType, vat, boxes, freshFrozen, comment, accountID, dayBookNo
FROM salesLedger WHERE balance <> 0 ORDER BY salesledger.customerID, invNum');
prepare stmt from @p_SQL;
execute stmt;

END


The second part of work (The insert) works fine. I just cant get the deletion to work at the beginning. The date I am inserting into the [entryDate] field is CURDATE(). But when I try to delete using the same CURDATE(), it does not delete anything ???

Any ideas ?

John

Options: ReplyQuote


Subject
Views
Written By
Posted
Rows not deleting from table
1120
February 25, 2019 08:00AM
370
February 25, 2019 02:28PM
357
February 26, 2019 03:49AM
332
March 09, 2019 03:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.