0
Talk about beauty?
Next, I am mounting a precedent, where I insert as parameter the number of lines that it will return and if it is 0 or is empty, it returns all possible lines, but in my logic is giving syntax error and so I needed your opinion. Follow what I’ve done:
CREATE DEFINER=`root`@`localhost` PROCEDURE `consultarPostagens`(
in cat varchar(40),
in limite int(11)
)
BEGIN
select * from tb_post where
( case when cat is null or cat = '' then categoria is not null
else categoria = cat end) and
( case when limite > 0 or limite <> '' then limit limite end )
END
In short, Procedure returns all posts and if a category is set, it brings all posts from that category.
The problem is on the edge, I do not know why I can not put within the case the term 'limit', he of the syntax error.
If anyone has any better idea of how to do or how to write this command, I would appreciate it.
Valeus!
I told you it wouldn’t work without looking at the code. I intend to remove my answer, you can accept yours even after, or that of someone who provides the correct answer. I cannot delete with it accept.
– Piovezan
But your answer made me think beyond... I’m new to the programming world and sometimes I need these triggers to solve certain problems. But thank you very much.
– Felipe Alves