2
I am creating a database to create a database and some tables within that database. I get the name of the database to be created by parameter.
I’m having difficulty concatenating this parameter next to the table creation script.
Below follows the code of what I did:
CREATE PROCEDURE criar_base_empresa(IN empresa VARCHAR(14))
BEGIN
CREATE DATABASE IF NOT EXISTS empresa;
CREATE TABLE IF NOT EXISTS empresa.`notas` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`dtEmissao` DATE NOT NULL,
`modelo` CHAR(2) NOT NULL,
`valor` FLOAT(9, 2) NOT NULL,
PRIMARY KEY (`id`)
);
END //
CALL criar_base_empresa('99999999999')
If I run, the base that is created is 'company' and not '99999999'.
It is worth noting that the name of the bank has only numbers, so you would have to put the name of the bank between `` (apostrophes).
Nothing done @Francisco, it’s syntax error.
– Meeeefiu