Delimiter //
/**	
 * Checks if the $col$ is not null
 *
 * @param varchar checkedFieldName
 * @param int batchnum
 * @param varchar errorsMsgsFieldName
 * @uses LOADER_CHECK_NULL()
 */
Drop Procedure if exists LOADER_CONTACTS_CHECK_NULL//

Create Procedure LOADER_CONTACTS_CHECK_NULL (
    In checkedFieldName varchar(70)
    , In batchnum int
    , In isWarning tinyint
    , In lastStatus varchar(150)
)
Begin

    Set @flagCountField='LOADER_CONTACTS_ERRCOUNT';
    Set @flagMsgField='LOADER_CONTACTS_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

    if Coalesce(isWarning, 0) = 1 Then
        Set @flagCountField='LOADER_CONTACTS_WARNCOUNT';
        Set @flagMsgField='LOADER_CONTACTS_WARNMSGS';
        Set @lastStatusField='';
        Set @lastStatus=lastStatus;
    End if;

    CALL LOADER_CHECK_NULL (
        'LOADER_CONTACTS'
        , checkedFieldName
        , 'LOADER_CONTACTS_BATCH_NUM'
        , batchnum
        , @flagCountField
        , @flagMsgField
        , @lastStatusField
        , @lastStatus
    );
End //
Delimiter ;