I want to create a SQL stored procedure that checks passwords at login. This should be a very common question however I could not find an answer anywhere to my specific question, which is about data types, or perhaps something like that. I am using a MySQL database but I am unsure what type of SQL I am using specifically. Here’s my SQL:
CREATE PROCEDURE SelectAllUsers @Password varchar(12)
AS
SELECT * FROM Logins WHERE Password = @Password
GO;
This image shows where I get an error for some reason, which is beyond me
2
Answers
You don’t specify the SQL dialecct that you are using, and the syntax can be different between them.
The following should work for Postgres:
You can find more information about the syntax in the docs: https://www.postgresql.org/docs/current/sql-createprocedure.html
If you are using MySQL, navigate to Stored Procedure under you DB Schema, right click and then click ‘Create Stored Procedure’. Copy below query. Change definer (
root
@localhost
) accordingly.