Mintendo
Mintendo

Reputation: 567

MySQL stored procedure return null

I have this stored procedure with out parameter (code):

SELECT code = RIGHT(CONCAT(REPEAT(0, 6), (SELECT MAX(CONVERT(code, int)) + 1 FROM enterprises)), 6)

If I exec it, return null value, but if I execute the single query, it works right. Why?

Upvotes: 0

Views: 674

Answers (1)

Devart
Devart

Reputation: 122032

Rename parameter, try to write something like this (parameter name code_param) -

SELECT
  RIGHT(CONCAT(REPEAT(0, 6), (SELECT MAX(CONVERT(code, int)) + 1 FROM enterprises)), 6)
INTO code_param;

Upvotes: 2

Related Questions