MySQL Forums
Forum List  »  MySQL Workbench

MYSQL triggers/procedures returning 0 in count query for a table even if there are records in that table
Posted by: Saurabh Khire
Date: February 17, 2022 04:51AM

In MYSQL Triggers , we check count for rows of table with where clause. Depending on that we have condition to only populate other table if row count is 0. So, if there are one or more rows in the table and we fire the query directly (without INTO) then we get count as 1 which is fair. But if we fire the same through trigger or procedure then we get count as 0. To debug the trigger I had put put the condition in stored procedure and found count was getting 0 even if there were rows in table
Could you please help with with the issue

Count query - SELECT COUNT(1) INTO RepCnt FROM REPLICATIONAUDIT WHERE (LTRIM(RTRIM(LOWER(REPLICATIONDESCRIPTION))) = 'full replication' OR LTRIM(RTRIM(LOWER(REPLICATIONDESCRIPTION))) LIKE '%base replication%') AND REPLICATIONSTATUSID = 1;

Options: ReplyQuote


Subject
Views
Written By
Posted
MYSQL triggers/procedures returning 0 in count query for a table even if there are records in that table
200
February 17, 2022 04:51AM


Sorry, only registered users may post in this forum.

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.