Richard Richard - 5 months ago 9x
SQL Question

MariaDB stored proc - Getting an error 'Missing SELECT' on INSERT statement

While I created loads of procs in SQL server, I want to start using MariaDB and so tried creating the simple proc below in MySQL Workbench.

I keep on getting an error stating that there is a missing SELECT on the opening '(' after the table name:

drop procedure if exists usp_AddSentEmail$$
CREATE PROCEDURE usp_AddSentEmail (in pSender varchar(36)
,in pTo varchar(1000)
,in pSubject varchar(100)
,in pBody varchar(10000)
,in pRecordDT datetime)
INSERT INTO Emails('To','Subject','Body','Sender','RecordDT','Sent','SentDT')
VALUES (pTo,pSubject,pBody,pSender,pRecordDT,1,pRecordDT);



Maybe I am trying the wrong google search but that all comes up is delimiter errors.


remove the quotes from the column names in your insert query:

INSERT INTO Emails(To,Subject,Body,Sender,RecordDT,Sent,SentDT) 
    VALUES (pTo,pSubject,pBody,pSender,pRecordDT,1,pRecordDT);