0

I'm trying to create a temporaryTable in a stored procedure with the following code:

   DELIMITER $$
CREATE PROCEDURE testprocedure 

AS

BEGIN

CREATE TEMPORARY TABLE Best_MitarbeiterLieferant 
(`enter code here`
    angestellter VARCHAR (50),
    AnzahlBestellungen INT NOT NULL,
    Lieferant VARCHAR(50)

)
#Test Datensatz
INSERT INTO Best_MitarbeiterLieferant VALUES ('Stefan', 12, 'UPS')
#Testabfrage
SELECT * FROM Best_MitarbeiterLieferant

# Tabelle wieder löschen
DROP TABLE Best_MitarbeiterLieferant
END $$

DELIMITER ;

But I am getting an error, and I don't know how to solve it. Appreciate help!

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS BEGIN CREATE TEMPORARY TABLE Best_MitarbeiterLieferant ( angeste' at line 3

Thanks in advance!

1 Answer 1

1

Try out this:

DELIMITER $$
CREATE PROCEDURE testprocedure()
BEGIN

CREATE TEMPORARY TABLE Best_MitarbeiterLieferant 
(   
    angestellter VARCHAR (50),
    AnzahlBestellungen INT NOT NULL,
    Lieferant VARCHAR(50)

);

#Test Datensatz
INSERT INTO Best_MitarbeiterLieferant VALUES ('Stefan', 12, 'UPS');
#Testabfrage
SELECT * FROM Best_MitarbeiterLieferant;

# Tabelle wieder löschen
DROP TABLE Best_MitarbeiterLieferant;
END $$

DELIMITER ;
Sign up to request clarification or add additional context in comments.

2 Comments

:Hey, this one worked out. I was about to try it with the ; but mysql told me "unexpected symbol" but it works! thank you for the super fast answer!
i will accept this as an answer, when it's available. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.