Modifications related to switch to sql.
Refactorisation to sql.
first works to sql.