730 lines
22 KiB
SQL
730 lines
22 KiB
SQL
|
|
USE demo;
|
|
|
|
DROP PROCEDURE IF EXISTS demo.p_ph_save_apply_founding_partner_form;
|
|
|
|
DELIMITER //
|
|
CREATE PROCEDURE demo.p_ph_save_apply_founding_partner_form (
|
|
IN a_comment VARCHAR(500),
|
|
IN a_guid BINARY(36),
|
|
IN a_id_user INT,
|
|
IN a_debug BIT
|
|
)
|
|
BEGIN
|
|
DECLARE v_code_type_error_bad_data VARCHAR(100);
|
|
DECLARE v_id_access_level_view INT;
|
|
DECLARE v_id_access_level_edit INT;
|
|
DECLARE v_id_change_set INT;
|
|
DECLARE v_id_permission_apply_founding_partner_form_admin INT;
|
|
DECLARE v_id_permission_apply_founding_partner_form_new INT;
|
|
DECLARE v_id_type_error_bad_data INT;
|
|
DECLARE v_time_start TIMESTAMP(6);
|
|
DECLARE v_can_admin BIT;
|
|
DECLARE v_can_create BIT;
|
|
|
|
DECLARE exit handler for SQLEXCEPTION
|
|
BEGIN
|
|
GET DIAGNOSTICS CONDITION 1
|
|
@sqlstate = RETURNED_SQLSTATE
|
|
, @errno = MYSQL_ERRNO
|
|
, @text = MESSAGE_TEXT
|
|
;
|
|
|
|
ROLLBACK;
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
|
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
|
, id_type INT
|
|
, code VARCHAR(50) NOT NULL
|
|
, msg VARCHAR(4000) NOT NULL
|
|
);
|
|
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
MET.id_type
|
|
, @errno
|
|
, @text
|
|
FROM demo.CORE_Msg_Error_Type MET
|
|
WHERE MET.code = 'MYSQL_ERROR'
|
|
;
|
|
|
|
SELECT *
|
|
FROM tmp_Msg_Error;
|
|
DROP TABLE IF EXISTS tmp_Msg_Error
|
|
;
|
|
END;
|
|
|
|
SET v_time_start := CURRENT_TIMESTAMP(6);
|
|
SET v_code_type_error_bad_data := 'BAD_DATA';
|
|
SET v_id_type_error_bad_data := (SELECT id_type FROM demo.CORE_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
|
|
SET v_id_permission_apply_founding_partner_form_admin := (SELECT id_permission FROM demo.DOG_Permission P WHERE P.code = 'CONTACT_FORM_ADMIN' LIMIT 1);
|
|
SET v_id_permission_apply_founding_partner_form_new := (SELECT id_permission FROM demo.DOG_Permission P WHERE P.code = 'CONTACT_FORM_CREATE' LIMIT 1);
|
|
|
|
CALL demo.p_core_validate_guid ( a_guid );
|
|
|
|
DROP TABLE IF EXISTS tmp_Apply_Founding_Partner_Form;
|
|
|
|
CREATE TEMPORARY TABLE tmp_Apply_Founding_Partner_Form (
|
|
id_apply_founding_partner_form INT NOT NULL
|
|
, name_contact VARCHAR(255)
|
|
, email VARCHAR(255)
|
|
, phone_number VARCHAR(255)
|
|
, name_company VARCHAR(255)
|
|
, website VARCHAR(1000)
|
|
, dog_count INT
|
|
, id_years_of_experience INT
|
|
, ids_speciality VARCHAR(255)
|
|
, ids_existing_system VARCHAR(255)
|
|
, existing_challenges TEXT
|
|
, id_existing_time_sink_weekly INT
|
|
, id_commitment_frequency INT
|
|
-- , most_valuable_features TEXT
|
|
, notes TEXT
|
|
, active BIT NOT NULL
|
|
, name_error VARCHAR(255)
|
|
, is_new BIT NOT NULL
|
|
);
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
|
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
|
, id_type INT
|
|
, code VARCHAR(50) NOT NULL
|
|
, msg VARCHAR(4000) NOT NULL
|
|
);
|
|
|
|
|
|
-- Get data from Temp table
|
|
INSERT INTO tmp_Apply_Founding_Partner_Form (
|
|
id_apply_founding_partner_form
|
|
, name_contact
|
|
, email
|
|
, phone_number
|
|
, name_company
|
|
, website
|
|
, dog_count
|
|
, id_years_of_experience
|
|
, ids_speciality
|
|
, ids_existing_system
|
|
, existing_challenges
|
|
, id_existing_time_sink_weekly
|
|
, id_commitment_frequency
|
|
-- , most_valuable_features
|
|
, notes
|
|
, active
|
|
, is_new
|
|
)
|
|
SELECT
|
|
AFPF_T.id_apply_founding_partner_form AS id_apply_founding_partner_form
|
|
, IFNULL(AFPF_T.name_contact, AFPF.name_contact) AS name_contact
|
|
, IFNULL(AFPF_T.email, AFPF.email) AS email
|
|
, IFNULL(AFPF_T.phone_number, AFPF.phone_number) AS phone_number
|
|
, IFNULL(AFPF_T.name_company, AFPF.name_company) AS name_company
|
|
, IFNULL(AFPF_T.website, AFPF.website) AS website
|
|
, IFNULL(AFPF_T.dog_count, AFPF.dog_count) AS dog_count
|
|
, IFNULL(AFPF_T.id_years_of_experience, AFPF.id_years_of_experience) AS id_years_of_experience
|
|
, IFNULL(AFPF_T.ids_speciality, AFPF.ids_speciality) AS ids_speciality
|
|
, IFNULL(AFPF_T.ids_existing_system, AFPF.ids_existing_system) AS ids_existing_system
|
|
, IFNULL(AFPF_T.existing_challenges, AFPF.existing_challenges) AS existing_challenges
|
|
, IFNULL(AFPF_T.id_existing_time_sink_weekly, AFPF.id_existing_time_sink_weekly) AS id_existing_time_sink_weekly
|
|
, IFNULL(AFPF_T.id_commitment_frequency, AFPF.id_commitment_frequency) AS id_commitment_frequency
|
|
-- , IFNULL(AFPF_T.most_valuable_features, AFPF.most_valuable_features) AS most_valuable_features
|
|
, IFNULL(AFPF_T.notes, AFPF.notes) AS notes
|
|
, COALESCE(AFPF_T.active, AFPF.active, 1) AS active
|
|
, CASE WHEN IFNULL(AFPF_T.id_apply_founding_partner_form, 0) < 1 THEN 1 ELSE 0 END AS is_new
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp AFPF_T
|
|
LEFT JOIN demo.PH_Apply_Founding_Partner_Form AFPF ON AFPF_T.id_apply_founding_partner_form = AFPF.id_apply_founding_partner_form
|
|
WHERE AFPF_T.guid = a_guid
|
|
;
|
|
|
|
UPDATE tmp_Apply_Founding_Partner_Form t_AFPF
|
|
SET name_error = COALESCE(t_AFPF.email, t_AFPF.name_company, t_AFPF.name_contact, t_AFPF.message, '(No Apply Founding Partner Form)')
|
|
;
|
|
|
|
-- Validation
|
|
-- Missing mandatory fields
|
|
-- name_contact
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.name_contact) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Contact Name: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.name_contact)
|
|
;
|
|
END IF;
|
|
-- email
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.email) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have an Email: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.email)
|
|
;
|
|
END IF;
|
|
/*
|
|
-- phone_number
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.phone_number) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Phone_number: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.phone_number)
|
|
;
|
|
END IF;
|
|
*/
|
|
-- name_company
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.name_company) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Company Name: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.name)
|
|
;
|
|
END IF;
|
|
/*
|
|
-- website
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.website) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Website: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.website)
|
|
;
|
|
END IF;
|
|
*/
|
|
-- dog_count
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.dog_count) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Dog_count: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.dog_count)
|
|
;
|
|
END IF;
|
|
-- id_years_of_experience
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.id_years_of_experience) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Id_years_of_experience: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.id_years_of_experience)
|
|
;
|
|
END IF;
|
|
-- ids_speciality
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.ids_speciality) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Ids_speciality: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.ids_speciality)
|
|
;
|
|
END IF;
|
|
-- ids_existing_system
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.ids_existing_system) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Ids_existing_system: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.ids_existing_system)
|
|
;
|
|
END IF;
|
|
-- existing_challenges
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.existing_challenges) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a existing_challenges: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.existing_challenges)
|
|
;
|
|
END IF;
|
|
-- id_existing_time_sink_weekly
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.id_existing_time_sink_weekly) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Id_existing_time_sink_weekly: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.id_existing_time_sink_weekly)
|
|
;
|
|
END IF;
|
|
-- id_commitment_frequency
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.id_commitment_frequency) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Id_commitment_frequency: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.id_commitment_frequency)
|
|
;
|
|
END IF;
|
|
/*
|
|
-- most_valuable_features
|
|
IF EXISTS (SELECT * FROM tmp_Apply_Founding_Partner_Form t_AFPF WHERE ISNULL(t_AFPF.most_valuable_features) LIMIT 1) THEN
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
SELECT
|
|
v_id_type_error_bad_data
|
|
, v_code_type_error_bad_data
|
|
, CONCAT('The following Apply Founding Partner Form(s) do not have a Most_valuable_features: ', GROUP_CONCAT(t_AFPF.name_error SEPARATOR ', ')) AS msg
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE ISNULL(t_AFPF.most_valuable_features)
|
|
;
|
|
END IF;
|
|
*/
|
|
|
|
-- Permissions
|
|
IF a_debug = 1 THEN
|
|
SELECT
|
|
a_guid
|
|
, 0 -- get_all_user
|
|
, 0 -- get_inactive_user
|
|
, a_id_user -- ids_user
|
|
, '' -- a_auth0_ids_user
|
|
, '' -- a_names_user
|
|
, '' -- a_emails_user
|
|
, 1 -- a_require_all_id_search_filters_met
|
|
, 1 -- a_require_any_id_search_filters_met
|
|
, 0 -- a_require_all_non_id_search_filters_met
|
|
, 0 -- a_require_any_non_id_search_filters_met
|
|
, v_id_permission_apply_founding_partner_form_admin -- ids_permission
|
|
, v_id_access_level_view -- ids_access_level
|
|
, 0 -- a_show_errors
|
|
, 0 -- a_debug
|
|
;
|
|
END IF;
|
|
|
|
CALL demo.p_dog_calc_user(
|
|
a_guid
|
|
, 0 -- get_all_user
|
|
, 0 -- get_inactive_user
|
|
, a_id_user -- ids_user
|
|
, '' -- a_auth0_ids_user
|
|
, '' -- a_names_user
|
|
, '' -- a_emails_user
|
|
, 1 -- a_require_all_id_search_filters_met
|
|
, 1 -- a_require_any_id_search_filters_met
|
|
, 0 -- a_require_all_non_id_search_filters_met
|
|
, 0 -- a_require_any_non_id_search_filters_met
|
|
, v_id_permission_apply_founding_partner_form_admin -- ids_permission
|
|
, v_id_access_level_view -- ids_access_level
|
|
, 0 -- a_show_errors
|
|
, 0 -- a_debug
|
|
);
|
|
|
|
SELECT
|
|
IFNULL(CALC_USER_T.has_access, 0)
|
|
INTO
|
|
v_can_admin
|
|
FROM demo.DOG_Calc_User_Temp CALC_USER_T
|
|
WHERE CALC_USER_T.GUID = a_guid
|
|
LIMIT 1
|
|
;
|
|
|
|
IF a_debug = 1 THEN
|
|
SELECT v_can_admin;
|
|
SELECT COUNT(*) AS Count_Errors FROM tmp_Msg_Error t_ERROR;
|
|
SELECT * FROM tmp_Msg_Error t_ERROR;
|
|
END IF;
|
|
|
|
CALL demo.p_dog_clear_calc_user(
|
|
a_guid
|
|
, 0 -- a_debug
|
|
);
|
|
|
|
|
|
IF a_debug = 1 THEN
|
|
SELECT
|
|
a_guid
|
|
, 0 -- get_all_user
|
|
, 0 -- get_inactive_user
|
|
, a_id_user -- ids_user
|
|
, '' -- a_auth0_ids_user
|
|
, '' -- a_names_user
|
|
, '' -- a_emails_user
|
|
, 1 -- a_require_all_id_search_filters_met
|
|
, 1 -- a_require_any_id_search_filters_met
|
|
, 0 -- a_require_all_non_id_search_filters_met
|
|
, 0 -- a_require_any_non_id_search_filters_met
|
|
, v_id_permission_apply_founding_partner_form_new -- ids_permission
|
|
, v_id_access_level_view -- ids_access_level
|
|
, 0 -- a_show_errors
|
|
, 0 -- a_debug
|
|
;
|
|
END IF;
|
|
|
|
CALL demo.p_dog_calc_user(
|
|
a_guid
|
|
, 0 -- get_all_user
|
|
, 0 -- get_inactive_user
|
|
, a_id_user -- ids_user
|
|
, '' -- a_auth0_ids_user
|
|
, '' -- a_names_user
|
|
, '' -- a_emails_user
|
|
, 1 -- a_require_all_id_search_filters_met
|
|
, 1 -- a_require_any_id_search_filters_met
|
|
, 0 -- a_require_all_non_id_search_filters_met
|
|
, 0 -- a_require_any_non_id_search_filters_met
|
|
, v_id_permission_apply_founding_partner_form_new -- ids_permission
|
|
, v_id_access_level_view -- ids_access_level
|
|
, 0 -- a_show_errors
|
|
, 0 -- a_debug
|
|
);
|
|
|
|
SELECT
|
|
IFNULL(CALC_USER_T.has_access, 0)
|
|
INTO
|
|
v_can_create
|
|
FROM demo.DOG_Calc_User_Temp CALC_USER_T
|
|
WHERE CALC_USER_T.GUID = a_guid
|
|
LIMIT 1
|
|
;
|
|
|
|
IF a_debug = 1 THEN
|
|
SELECT v_can_create;
|
|
SELECT COUNT(*) AS Count_Errors FROM tmp_Msg_Error t_ERROR;
|
|
SELECT * FROM tmp_Msg_Error t_ERROR;
|
|
END IF;
|
|
|
|
CALL demo.p_dog_clear_calc_user(
|
|
a_guid
|
|
, 0 -- a_debug
|
|
);
|
|
|
|
IF (v_can_admin = 0 AND EXISTS(SELECT * FROM tmp_Apply_Founding_Partner_Form WHERE is_new = 0)) THEN
|
|
DELETE t_ME
|
|
FROM tmp_Msg_Error t_ME
|
|
WHERE t_ME.id_type <> v_id_type_error_no_permission
|
|
;
|
|
INSERT INTO tmp_Msg_Error (
|
|
id_type
|
|
, code
|
|
, msg
|
|
)
|
|
VALUES (
|
|
v_id_type_error_no_permission
|
|
, v_code_type_error_no_permission
|
|
, 'You do not have permission to admin Apply Founding Partner Forms.'
|
|
)
|
|
;
|
|
END IF;
|
|
|
|
IF EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
|
IF a_debug = 1 THEN
|
|
SELECT * from tmp_Apply_Founding_Partner_Form;
|
|
END IF;
|
|
|
|
DELETE FROM tmp_Apply_Founding_Partner_Form;
|
|
END IF;
|
|
|
|
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
|
START TRANSACTION;
|
|
|
|
INSERT INTO demo.PH_Contact_Form_Change_Set (
|
|
comment
|
|
, id_user_updated_last_by
|
|
, updated_last_on
|
|
)
|
|
VALUES (
|
|
a_comment
|
|
, a_id_user
|
|
, v_time_start
|
|
)
|
|
;
|
|
|
|
SET v_id_change_set := LAST_INSERT_ID();
|
|
|
|
UPDATE demo.PH_Apply_Founding_Partner_Form AFPF
|
|
INNER JOIN tmp_Apply_Founding_Partner_Form t_AFPF
|
|
ON AFPF.id_apply_founding_partner_form = t_AFPF.id_apply_founding_partner_form
|
|
AND t_AFPF.is_new = 0
|
|
SET
|
|
AFPF.name_contact = t_AFPF.name_contact
|
|
, AFPF.email = t_AFPF.email
|
|
, AFPF.phone_number = t_AFPF.phone_number
|
|
, AFPF.name_company = t_AFPF.name_company
|
|
, AFPF.website = t_AFPF.website
|
|
, AFPF.dog_count = t_AFPF.dog_count
|
|
, AFPF.id_years_of_experience = t_AFPF.id_years_of_experience
|
|
, AFPF.ids_speciality = t_AFPF.ids_speciality
|
|
, AFPF.ids_existing_system = t_AFPF.ids_existing_system
|
|
, AFPF.existing_challenges = t_AFPF.existing_challenges
|
|
, AFPF.id_existing_time_sink_weekly = t_AFPF.id_existing_time_sink_weekly
|
|
, AFPF.id_commitment_frequency = t_AFPF.id_commitment_frequency
|
|
-- , AFPF.most_valuable_features = t_AFPF.most_valuable_features
|
|
, AFPF.notes = t_AFPF.notes
|
|
, AFPF.active = t_AFPF.active
|
|
, AFPF.id_change_set = v_id_change_set
|
|
;
|
|
|
|
INSERT INTO demo.PH_Apply_Founding_Partner_Form (
|
|
name_contact
|
|
, email
|
|
, phone_number
|
|
, name_company
|
|
, website
|
|
, dog_count
|
|
, id_years_of_experience
|
|
, ids_speciality
|
|
, ids_existing_system
|
|
, existing_challenges
|
|
, id_existing_time_sink_weekly
|
|
, id_commitment_frequency
|
|
-- , most_valuable_features
|
|
, notes
|
|
, active
|
|
, id_user_created_by
|
|
, created_on
|
|
)
|
|
SELECT
|
|
t_AFPF.name_contact
|
|
, t_AFPF.email
|
|
, t_AFPF.phone_number
|
|
, t_AFPF.name_company
|
|
, t_AFPF.website
|
|
, t_AFPF.dog_count
|
|
, t_AFPF.id_years_of_experience
|
|
, t_AFPF.ids_speciality
|
|
, t_AFPF.ids_existing_system
|
|
, t_AFPF.existing_challenges
|
|
, t_AFPF.id_existing_time_sink_weekly
|
|
, t_AFPF.id_commitment_frequency
|
|
-- , t_AFPF.most_valuable_features
|
|
, t_AFPF.notes
|
|
, t_AFPF.active
|
|
, a_id_user
|
|
, v_time_start
|
|
FROM tmp_Apply_Founding_Partner_Form t_AFPF
|
|
WHERE
|
|
t_AFPF.is_new = 1
|
|
AND t_AFPF.active = 1
|
|
;
|
|
|
|
COMMIT;
|
|
END IF;
|
|
|
|
START TRANSACTION;
|
|
|
|
DELETE FROM demo.PH_Apply_Founding_Partner_Form_Temp
|
|
WHERE GUID = a_guid
|
|
;
|
|
|
|
COMMIT;
|
|
|
|
-- Errors
|
|
SELECT *
|
|
FROM tmp_Msg_Error t_ME
|
|
INNER JOIN demo.CORE_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
|
|
;
|
|
|
|
IF a_debug = 1 THEN
|
|
SELECT * from tmp_Apply_Founding_Partner_Form;
|
|
END IF;
|
|
|
|
DROP TEMPORARY TABLE tmp_Apply_Founding_Partner_Form;
|
|
DROP TEMPORARY TABLE tmp_Msg_Error;
|
|
|
|
IF a_debug = 1 THEN
|
|
CALL demo.p_core_debug_timing_reporting ( v_time_start );
|
|
END IF;
|
|
END //
|
|
DELIMITER ;
|
|
|
|
/*
|
|
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form;
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp;
|
|
|
|
|
|
|
|
INSERT INTO demo.PH_Apply_Founding_Partner_Form_Temp (
|
|
id_apply_founding_partner_form
|
|
,name_contact
|
|
, email,
|
|
phone_number
|
|
,name_company
|
|
,website
|
|
,dog_count
|
|
,id_years_of_experience
|
|
,ids_speciality
|
|
,ids_existing_system
|
|
,existing_challenges
|
|
,id_existing_time_sink_weekly
|
|
,id_commitment_frequency
|
|
,notes
|
|
,active
|
|
,guid
|
|
)
|
|
SELECT
|
|
id_apply_founding_partner_form
|
|
,name_contact
|
|
, email,
|
|
phone_number
|
|
,name_company
|
|
,website
|
|
,dog_count
|
|
,id_years_of_experience
|
|
,ids_speciality
|
|
,ids_existing_system
|
|
,existing_challenges
|
|
,id_existing_time_sink_weekly
|
|
,id_commitment_frequency
|
|
,notes
|
|
,active
|
|
, '782c29e0-72e6-41e2-b543-4b0454041a57'
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp
|
|
WHERE guid = '782c29e0-72e6-41e2-b543-4b0454041a56';
|
|
|
|
|
|
CALL demo.p_ph_save_apply_founding_partner_form (
|
|
'nipples'
|
|
, (SELECT GUID FROM demo.PH_Apply_Founding_Partner_Form_Temp ORDER BY id_temp DESC LIMIT 1)
|
|
, 1
|
|
, 1
|
|
);
|
|
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form;
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp;
|
|
|
|
|
|
|
|
*/
|
|
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form;
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp;
|
|
|
|
|
|
|
|
INSERT INTO demo.PH_Apply_Founding_Partner_Form_Temp (
|
|
id_apply_founding_partner_form
|
|
,name_contact
|
|
, email,
|
|
phone_number
|
|
,name_company
|
|
,website
|
|
,dog_count
|
|
,id_years_of_experience
|
|
,ids_speciality
|
|
,ids_existing_system
|
|
,existing_challenges
|
|
,id_existing_time_sink_weekly
|
|
,id_commitment_frequency
|
|
,notes
|
|
,active
|
|
,guid
|
|
)
|
|
SELECT
|
|
id_apply_founding_partner_form
|
|
,name_contact
|
|
, email,
|
|
phone_number
|
|
,name_company
|
|
,website
|
|
,dog_count
|
|
,id_years_of_experience
|
|
,ids_speciality
|
|
,ids_existing_system
|
|
,existing_challenges
|
|
,id_existing_time_sink_weekly
|
|
,id_commitment_frequency
|
|
,notes
|
|
,active
|
|
, '782c29e0-72e6-41e2-b543-4b0454041a57'
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp
|
|
WHERE guid = '782c29e0-72e6-41e2-b543-4b0454041a56';
|
|
|
|
|
|
CALL demo.p_ph_save_apply_founding_partner_form (
|
|
'nipples'
|
|
, (SELECT GUID FROM demo.PH_Apply_Founding_Partner_Form_Temp ORDER BY id_temp DESC LIMIT 1)
|
|
, 1
|
|
, 1
|
|
);
|
|
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form;
|
|
SELECT *
|
|
FROM demo.PH_Apply_Founding_Partner_Form_Temp;
|
|
|