1
DELIMITER $$
     CREATE DEFINER=`axistms`@`localhost` FUNCTION `CheckDoc`(`orderId` INT) RETURNS int(11)
DETERMINISTIC
BEGIN
     DECLARE lvl int;
     SELECT count(`id`) INTO lvl FROM `com_carrier_portal_upload_documents` WHERE `orderID`= orderId;
     RETURN lvl;
END$$
DELIMITER ;

any order id pass through orderId parameter its doesn't effect on where condition. Always return count of all records.How to fix this?

1 Answer 1

1

I'd suggest you to rename stored procedure argument, do something like this -

CREATE DEFINER = `axistms`@`localhost` FUNCTION `CheckDoc` (orderIdParam int)
RETURNS int(11)
DETERMINISTIC
BEGIN
  DECLARE lvl int;
  SELECT
    COUNT(`id`) INTO lvl
  FROM `com_carrier_portal_upload_documents`
  WHERE `orderID` = orderIdParam;
  RETURN lvl;
END

...because WHERE orderID= orderId can be equal to WHERE true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.