Determine the database name inside of stored procedure - mysql

I've created a stored procedure in Mysql and I was wondering if there is a command that I can get and store the name of the database that this stored procedure lives in?

How about DATABASE() ?
(This text is just filler)

Your Question is wrong?..Your actual question is you have created a stored procedure inside the databases...not how to retrieve the procedure inside the database?
Ans: To know the created procedure:
mysql:\> show procedure status; //to know the procedure name..sam4 function show function staus;
mysql:\> show use create procedure emptab.test1 //emptab is database name,test1 is the procedure..

Related

MySQL how to use stored procedures to create database users?

I want to write a stored procedure that allows people to create new database users.
I've looked up on the Internet and it seems that the only answer I find is too complex (MySQL Stored Procedure to create user)
This is what I have, but it is not working. MySQL complains about 'psw'.
create procedure create_user(IN name varchar(50), IN psw varchar(50))
begin
create user name identified by psw;
end
I'd like to know if it is possible to implement the procedure following the logic of the one I presented, and if so, how it is done

Call stored procedure from stored procedure in MySQL

i'm new to MySQL.
I need to call stored procedure from a stored procedure and use the first stored procedure as a table.
How to do this without use temporary table?
How to do this without use temporary table?
create a fact table then
Not sure why there is a requirement saying: can't use temporary table as you are using store procedure. but that must be unreasonable.
if the RDBS takes care of that for you , the underlying mechanism is still store the 1st result set somewhere in the memory as middle step result. temporary table for you.
so just: create a temporary table, call the store procedure, insert data into that . why not

pdo/mysql create procedure

I'd like to create a procedure from PHP using PDO...I can execute the procedure with PDO, I can create the procedure with the console line or with phpmyadmin, but I'm not able to create this very same procedure from PDO...
I absolutely need to be able to create this procedure from my php code (it's a setup part of a bigger program, the first step checks if the procedure exists with
SHOW PROCEDURE STATUS LIKE 'name_of_procedure'
if the procedure doesn't exists, I try (but fail) to create it (with prepare/execute couple of methods).

MySQL : How to link a stored procedure to a table

How can I link a stored procedure to a temporary table?
I had a database created named Multi. All the attributes of table registration are copied into the stored procedure. In this you cannot insert from stored procedure. This is just creating a stored procedure and giving it something to hold.
This is the example of it.

Mysql Create Table with dynamic database name

I am creating database at runtime and I want to create the tables in that database at the same time. Can anyone give me any thought on how to do that?
For Example -
I have created one database named 'mydb'
and now in the same process I am trying to create the table I am using the mysql stored procedure for the same.
My proc input will be my dbname. So, my proc looks like
create procedure test(IN dbname varchar(100))
begin
create table `dbname`.`testing`(testid int, testname varchar(45));
end
You can use the PREPARE feature to execute dynamic SQL.