0
votes

I am trying to store table results of two stored procedures to a single table in phpmyadmin routine window which gives me mariadb syntax error. Calling the stored procedures separately gives me the results.

Stored procedure code

BEGIN
CREATE TABLE temp(Name VARCHAR(200), Value1 varchar(100), Value2 varchar(100))
INSERT INTO temp CALL stored_procedure1();
INSERT INTO temp CALL stored_procedure2();
END

This code gives me the following syntax error

The following query has failed:

"CREATE DEFINER=`root`@`localhost` PROCEDURE `get_data`() NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER BEGIN CREATE TABLE temp(Name VARCHAR(200), Value1 varchar(100), Value2 varchar(100)) INSERT INTO temp CALL stored_procedure1(); INSERT INTO temp CALL stored_procedure2(); END"

MySQL said: #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 'INSERT INTO temp CALL stored_procedure1();

I tried changing syntax of TABLE temp to TABLE #temp and adding ; at the end of create table statement which did not resolve it.

1

1 Answers

0
votes

First, you should change default delimiter which is ; to something like //

Also, i assume you forgot to put CREATE PROCEDURE Something() statement here.

DELIMITER //
CREATE PROCEDURE Something()
BEGIN
CREATE TABLE temp(Name VARCHAR(200), Value1 varchar(100), Value2 varchar(100));
INSERT INTO temp CALL stored_procedure1();
INSERT INTO temp CALL stored_procedure2();
END//
DELIMITER ;