I don’t know where I’m going wrong with store creation

Asked

Viewed 35 times

1

Somebody help me?

CREATE PROCEDURE 'sp_pessoas_insert' (  pessoa INT(11),
    name VARCHAR(20),
    lastname VARCHAR(55), 
    age CHARACTER(2),
    genre boolean,
    countrie CHARACTER(2),
    state INT(11),
    city INT(11),
    income CHARACTER(8),
    email VARCHAR(100),
    password VARCHAR(100) ) BEGIN

    INSERT INTO person VALUES(pessoa, name, lastname, age, genre, countrie, state, city, income, email, password)

    SELECT * FROM person WHERE id =  LAST_INSERT_ID();
     END

Return me the error: ERRO AO CRIAR PROCEDURE

I’ve been through everything and I can’t solve this problem by creating the trial, you can help me and explain if it’s possible what’s happening?!

  • These simple quotes in the Procedure name exist in SQL syntax?

  • as @Andersoncarloswoss noted should be the problem, in mysql crase instead of single quotes for names

  • Thank you all for taking the time to help me. really the error was the simple quotes, I’m starting to mess with procedures and I’m also new here in the stack, I want to ask for help on how to evaluate your response.

1 answer

2

The error as pointed out in the comments is that you are using simple quotes ( ' ) instead of the apostrophe ( ` ) to identify the name of the past.

Another thing that’s not a mistake, but it’s a syntax will be discontinued is the integer display width (those numbers in parentheses from the INT). You don’t need them.

Follow a modified version of Precedent compiling in mysql 8.

DELIMITER $$

CREATE  PROCEDURE `sp_pessoas_insert` (  
    pessoa INT,
    name VARCHAR(20),
    lastname VARCHAR(55), 
    age CHARACTER(2),
    genre boolean,
    countrie CHARACTER(2),
    state INT,
    city INT,
    income CHARACTER(8),
    email VARCHAR(100),
    password VARCHAR(100) ) 
BEGIN
    INSERT INTO person VALUES(pessoa, name, lastname, age, genre, countrie, state, city, income, email, password);
    SELECT * FROM person WHERE id = LAST_INSERT_ID();
END$$

DELIMITER ;
  • Vlw again Fabiano I will evaluate the answer, and if it is not ask much how I can mark the issue as resolved?

  • Sure! Thanks. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.