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_ENTRIES_CHECK_FIELD_LENGTH//

Create Procedure LOADER_ENTRIES_CHECK_FIELD_LENGTH (
    In checkedFieldName varchar(70)
    , In minlength int
    , In maxlength int
    , In batchnum int
    , In isWarning tinyint
    , In lastStatus varchar(150)
)
Begin
    Set @flagCountField='LOADER_ENTRIES_ERRCOUNT';
    Set @flagMsgField='LOADER_ENTRIES_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

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


    CALL LOADER_CHECK_FIELD_LENGTH (
        'LOADER_ENTRIES'
        , checkedFieldName
        , minlength
        , maxlength
        , 'LOADER_ENTRIES_BATCH_NUM'
        , batchnum
        , @flagCountField
        , @flagMsgField
        , @lastStatusField
        , @lastStatus
    );
End //
Delimiter ;