Store procedures in phpMyAdmin

I have to add stored procedures to the MySQL database.

The problem is that hosting offers phpMyAdmin to manage the database.

I searched the Internet, and the idea is to run my own MySQL statement, which creates procedures, but since the procedure code can often have ; , we have to change the delimiter in MySQL.

phpMyAdmin does not have this option. Has anyone tried to create stored procedures manually by setting an anchor or something that worked?

+5
source share
6 answers

There is a way, see this link: http://blog.nth-design.com/2009/02/25/creating-sp-in-phpmyadmin/

Quote from this link
1.Open phpMyadmin.
2. Select a database to work with.
3. Click the SQL tab.
4.Select all the SQL statements between the DELIMITER statements in the script stored procedure. Do not include DELIMITER instructions! Here's what my sample script looks like:

 DROP PROCEDURE IF EXISTS spFoo $$ CREATE PROCEDURE spFoo () BEGIN SELECT 'Foo' FROM DUAL; END $$ 

5. In the separator box just below the text area of ​​the SQL editor, enter $$ as the separator.

+8
source

Why is everyone trying to use a visual tool as a console?!? There is an easier way:

Go to your database and find "More"

enter image description here

This screen will then be displayed. If you created any stored procedures, they will be listed.

enter image description here

To add a new one click "Add Procedure"

enter image description here

+4
source

Try creating / editing stored procedures and other MySQL objects with visual object editors in dbForge Studio for MySQL . Express Edition is free.


  • Connection question - what if there is no direct connection to the MySQL server? Possible ways: HTTP tunneling - can be used to connect to the MySQL server, this is a method of connecting to the server using HTTP / HTTPS or using a secure connection (network protocol SSH / SSL).
  • The DELIMITER client team is supported by the proposed tool. Thus, this command can be used in scripts. In addition, stored procedures and other objects can be created and modified in visual editors.
0
source

You can set the delimiter manually using delimiter $$ , where $$ is your chosen delimiter. This works on my shared hosting with phpMyAdmin. You must remember that after completion press ; .

0
source

create sp_helpme procedure start select * from my_table; end //

Separators in MySQL .

You must change the ';' to '//' on the dividing field in phpmyadmin. After successful completion, return the delimeter.

0
source

I had a problem using the "Routines" function in PHPMyadmin because it gave me false negatives, so I did it using the "SQL" tab.

 CREATE PROCEDURE GetUserPwd(email VARCHAR(320), pass VARCHAR(128)) BEGIN DECLARE userid INT(3) DEFAULT 0; DECLARE password_equal INT(3) DEFAULT 0; DECLARE output VARCHAR(30); SELECT id INTO userid FROM members WHERE user_email = email; IF userid != 0 THEN SELECT user_pass = pass INTO password_equal FROM members WHERE id = userid; IF password_equal = 0 THEN SET output = 'not exist'; ELSE SET output = 'exist'; END IF; END IF; SELECT output; END 

In the Separator text box, enter $$. save.

after that, go to the "Subprograms" tab and click "execute" and enter your inputs when prompted.

0
source

Source: https://habr.com/ru/post/959123/


All Articles