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

Create Procedure LOADER_ACCOUNTS_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_ACCOUNTS_ERRCOUNT';
    Set @flagMsgField='LOADER_ACCOUNTS_ERRMSGS';
    Set @lastStatusField=null;
    Set @lastStatus=null;

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


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