Delimiter $$
/**
 * Author:  armen
 * Created: 21 juin 2018
 */


--  diaries
Drop Procedure if Exists BUSINESS_COMPUTE_PUBLICVIEWS_DIARIES $$
Create Procedure BUSINESS_COMPUTE_PUBLICVIEWS_DIARIES ()
Begin
    Truncate Table TMP_V_PUBLIC_DIARIES_VIEW;

    Insert Into TMP_V_PUBLIC_DIARIES_VIEW (
        ID_EVENTS
        , ENTITIES_ID_ENTITIES
        , ENTITIES_CODE
        , ENTITIES_BUSINESS_BRAND_NAME
        , ENTITIES_BUSINESS_COMPANY_NAME
        , ENTITIES_BUSINESS_SIRET
        , ENTITIES_MAJOR_SANDBOX
        , ENTITIES_SANDBOX_MODE
        , ID_ENTITIES_AGENCIES
        , ENTITIES_AGENCIES_CODE
        , ACCOUNTS_ID_ACCOUNTS
        , ACCOUNTS_REF
        , ACCOUNTS_BUSINESS_BRAND_NAME
        , ACCOUNTS_BUSINESS_COMPANY_NAME
        , ACCOUNTS_BUSINESS_SIRET
        , ACCOUNTS_INDIVIDUAL_FIRST_NAME
        , ACCOUNTS_INDIVIDUAL_LAST_NAME
        , ACCOUNTS_INDIVIDUAL_BIRTH_NAME
        , EVENTS_DATE_EXPECTED_START
        , EVENTS_DATE_EXPECTED_END
        , EVENTS_DATE_CLOSED
        , EVENTS_IS_DONE
        , EVENTS_NOTES
        , ID_DF_TASKS
        , DF_TASKS_CODE
        , DF_TASKS_LABEL
        , TASKS_PLANS_CONT_FREEZE
        , TASKS_PLANS_CODE
        , TASKS_PLANS_LABEL
        , DF_TASKS_PLANS_CODE
        , DF_TASKS_PLANS_LABEL
        , AUTHOR_ID_MEMBERS
        , AUTHOR_MEMBERS_LOGIN
        , AUTHOR_MEMBERS_GLOBAL_NAME
        , TASK_TYPE
    )
    Select 
        ID_EVENTS
        , ENTITIES_ID_ENTITIES
        , ENTITIES_CODE
        , ENTITIES_BUSINESS_BRAND_NAME
        , ENTITIES_BUSINESS_COMPANY_NAME
        , ENTITIES_BUSINESS_SIRET
        , ENTITIES_MAJOR_SANDBOX
        , ENTITIES_SANDBOX_MODE
        , ID_ENTITIES_AGENCIES
        , ENTITIES_AGENCIES_CODE
        , ACCOUNTS_ID_ACCOUNTS
        , ACCOUNTS_REF
        , ACCOUNTS_BUSINESS_BRAND_NAME
        , ACCOUNTS_BUSINESS_COMPANY_NAME
        , ACCOUNTS_BUSINESS_SIRET
        , ACCOUNTS_INDIVIDUAL_FIRST_NAME
        , ACCOUNTS_INDIVIDUAL_LAST_NAME
        , ACCOUNTS_INDIVIDUAL_BIRTH_NAME
        , EVENTS_DATE_EXPECTED_START
        , EVENTS_DATE_EXPECTED_END
        , EVENTS_DATE_CLOSED
        , EVENTS_IS_DONE
        , EVENTS_NOTES
        , ID_DF_TASKS
        , DF_TASKS_CODE
        , DF_TASKS_LABEL
        , TASKS_PLANS_CONT_FREEZE
        , TASKS_PLANS_CODE
        , TASKS_PLANS_LABEL
        , DF_TASKS_PLANS_CODE
        , DF_TASKS_PLANS_LABEL
        , AUTHOR_ID_MEMBERS
        , AUTHOR_MEMBERS_LOGIN
        , AUTHOR_MEMBERS_GLOBAL_NAME
        , TASK_TYPE
    From V_PUBLIC_DIARIES_VIEW ;
End $$
Delimiter ;
