def makeNextFreeFunc( table, var ):
        """
        Make a function that finds the next highest value of
        an integer field; used to auto-increment inserts for integer parts of a primary key
        """
        template = Template( file=templatesPath()+"get_next_free.func.tmpl" )
        template.functionHeader = makeNextFreeHeader( var, CONNECTION_STRING, ' is' )
        template.statement = "select coalesce( max( "+var.varname+" ) + 1, 1 ) from "+table.qualifiedName()
        template.functionName = "Next_Free_"+var.adaName
        template.adaName = var.adaName
        template.default = var.getDefaultAdaValue()
        template.adaType = var.getAdaType( True )
        template.getFunction = makeValueFunction( var, "0", "0" )
        return str( template );
def makeNextFreeFunc( table, var ):
        """
        Make a function that finds the next highest value of
        an integer field; used to auto-increment inserts for integer parts of a primary key
        """
        template = Template( file=templatesPath()+"get_next_free.func.tmpl" )
        template.functionHeader = makeNextFreeHeader( var, CONNECTION_STRING, ' is' )
        template.statement = "select max( "+var.varname+" ) from "+table.qualifiedName()
        template.functionName = "Next_Free_"+var.adaName
        template.adaName = var.adaName
        template.adaType = var.getAdaType( True )
        template.default = var.getDefaultAdaValue()
        if( var.sqlType == 'BIGINT' ):
                template.whichBinding = 'L'
        else:
                template.whichBinding = 'I'
        s = str(template) 
        return s