Skip to content

Instantly share code, notes, and snippets.

@genakim
Created May 12, 2020 19:36
Show Gist options
  • Save genakim/576e45cb42f66c345ec7d36756166ef6 to your computer and use it in GitHub Desktop.
Save genakim/576e45cb42f66c345ec7d36756166ef6 to your computer and use it in GitHub Desktop.
Пример функции MySQL
create
definer = root@`::1` function updatePublicWorksDate(serviceLogId int, date date, dateId varchar(255)) returns date
BEGIN
IF (dateId = 'REFERRAL_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.REFERRAL_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
IF (dateId = 'PW_SENT_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.PW_SENT_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
IF (dateId = 'PW_DENY_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.PW_DENY_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
IF (dateId = 'PW_STOP_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.PW_STOP_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
IF (dateId = 'PW_USE_DATE') THEN
UPDATE m_service_public_works mspw
SET mspw.PW_USE_DATE = date
WHERE mspw.SERVICE_LOG_ID = serviceLogId;
END IF;
RETURN date;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment