Scenario: I have a table in a mariaDB. It’s called “pages”. It just has three columns and a few entries for test purposes.
Problem: I try to create a nice PREPARE statement in SQL. I did not get it working so I ended up with the following ‘simple’ code.
PREPARE stmt from 'SELECT * FROM `pages`;';
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
It does kind of execute without errors, but it does not show a single row.
What am I missing here?
If you are asking, why I use a prepare statement for such a simple query: It is just for finding the error. The final query will be more complicated with variables etc.
Thanks in advance!
P.S.: Could be a double of Select * for mysql prepare statement not listing anything but maybe not.
Additional Info I run the code as a direct SQL Query in Sequel Pro.
RIGHT ANSWER
Joakim Danielson had the right guess.
prepare stmt from 'SELECT * FROM `pages`;'; execute stmt;
DEALLOCATE PREPARE stmt;
This works in Sequel Pro. BUT I totally recommend to not use Sequel Pros command line. Other bugs occurred one after another. Not so in the mysql CLI. Better go with your OS’ command line.
This has something to do with Sequel Pro then I guess. If you first run the prepare
and execute
rows together it will work and show some output, at least it did for me, and then run the deallocate
separately. I also tried from the command line and it worked fine there too.