MySql_Email.sql
1.25 KB
--DROP TABLE IF EXISTS tool_EmailList;
CREATE TABLE tool_EmailList (
ID int(11) UNSIGNED NOT NULL,
NickName varchar(20) NOT NULL,
EMail varchar(256) NOT NULL,
FirstName varchar(150) NOT NULL,
SurName varchar(100) NOT NULL,
Text text NOT NULL,
KindOfList varchar(20) NOT NULL,
CreateDate timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
UNIQUE (NickName,KindOfList)
) ENGINE=InnoDB;
INSERT INTO tool_EmailList (ID, NickName, EMail, FirstName, SurName, Text, KindOfList) VALUES ('0', 'NickName', 'EMail', 'FirstName', 'SurName', 'Text', 'KindOfList');
select 'CREATE FUNCTION tool_insertEmailToList(...) RETURNS INT';
DROP FUNCTION IF EXISTS tool_insertEmailToList;
DELIMITER '$';
CREATE FUNCTION tool_insertEmailToList(param_NickName varchar(20), param_EMail varchar(256), param_FirstName varchar(150), param_SurName varchar(100), param_Text text, param_KindOfList varchar(20))
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE var_NewID INT;
set var_NewID=(select max(ID) as ID from tool_EmailList)+1;
INSERT INTO tool_EmailList (ID, NickName, EMail, FirstName, SurName, Text, KindOfList)
VALUES (var_NewID, param_NickName, param_EMail, param_FirstName, param_SurName, param_Text, param_KindOfList);
return var_NewID;
END;
$
DELIMITER ;