TRUNCATE table value_assoc;
TRUNCATE table input_val;
TRUNCATE table result_val;
TRUNCATE table input;
TRUNCATE table result;


insert into input(name) values('S');insert into input_val(value, input_id, title) select '1', i.id, 'A partir du prix du logement' from input i where i.name='S';insert into input_val(value, input_id, title) select '2', i.id, 'A partir de votre capacité d\'épargne mensuelle ' from input i where i.name='S';insert into input(name) values('SC');insert into input_val(value, input_id, title) select '1', i.id, 'Scellier classique' from input i where i.name='SC';insert into input_val(value, input_id, title) select '2', i.id, 'Scellier social' from input i where i.name='SC';insert into input_val(value, input_id, title) select '3', i.id, 'Scellier BBC' from input i where i.name='SC';insert into input_val(value, input_id, title) select '4', i.id, 'Scellier social BBC' from input i where i.name='SC';insert into input(name) values('PRIX');insert into input(name) values('INST');insert into input(name) values('F');insert into input_val(value, input_id, title) select '1', i.id, 'Celibataire / concubin' from input i where i.name='F';insert into input_val(value, input_id, title) select '2', i.id, 'Marié / Pacsé' from input i where i.name='F';insert into input_val(value, input_id, title) select '3', i.id, 'Divorcé' from input i where i.name='F';insert into input_val(value, input_id, title) select '4', i.id, 'Veuf' from input i where i.name='F';insert into input(name) values('NBCHILD');insert into input_val(value, input_id, title) select '0', i.id, '0' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '1', i.id, '1' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '2', i.id, '2' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '3', i.id, '3' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '4', i.id, '4' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '5', i.id, '5' from input i where i.name='NBCHILD';insert into input_val(value, input_id, title) select '6', i.id, '6' from input i where i.name='NBCHILD';insert into input(name) values('RAN');insert into input(name) values('CLASS');insert into input_val(value, input_id, title) select '1', i.id, 'Oui' from input i where i.name='CLASS';insert into input_val(value, input_id, title) select '0', i.id, 'Non' from input i where i.name='CLASS';insert into input(name) values('RENOV');insert into input_val(value, input_id, title) select '1', i.id, 'Oui' from input i where i.name='RENOV';insert into input_val(value, input_id, title) select '0', i.id, 'Non' from input i where i.name='RENOV';insert into input(name) values('TRAVPRIX');insert into input(name) values('GOODS');insert into input(name) values('LOANS');insert into input(name) values('LastIR');insert into input(name) values('ALIMONY');insert into input(name) values('NBCHARGE');insert into input_val(value, input_id, title) select '0', i.id, '0' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '1', i.id, '1' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '2', i.id, '2' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '3', i.id, '3' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '4', i.id, '4' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '5', i.id, '5' from input i where i.name='NBCHARGE';insert into input_val(value, input_id, title) select '6', i.id, '6' from input i where i.name='NBCHARGE';insert into input(name) values('ImmoGoods');insert into input(name) values('PrimaryResidence');insert into input(name) values('LLuser');insert into input(name) values('LRuser');insert into input(name) values('LIuser');insert into input(name) values('LC');insert into input(name) values('SIuser');insert into input(name) values('SLuser');insert into input(name) values('SRuser');insert into input(name) values('Capital');insert into input(name) values('SInst');insert into input(name) values('SLtype');insert into input_val(value, input_id, title) select 'mois', i.id, 'par mois' from input i where i.name='SLtype';insert into input_val(value, input_id, title) select 'trim', i.id, 'par trimestre' from input i where i.name='SLtype';insert into input_val(value, input_id, title) select 'an', i.id, 'par an' from input i where i.name='SLtype';insert into input(name) values('Sfrom');insert into input_val(value, input_id, title) select '1', i.id, 'de vos mensualités' from input i where i.name='Sfrom';insert into input_val(value, input_id, title) select '2', i.id, 'du capital à atteindre' from input i where i.name='Sfrom';insert into input(name) values('MATRIM');insert into input_val(value, input_id, title) select '1', i.id, 'Communauté réduite aux acquêts' from input i where i.name='MATRIM';insert into input_val(value, input_id, title) select '2', i.id, 'Séparation de biens' from input i where i.name='MATRIM';insert into input_val(value, input_id, title) select '3', i.id, 'Communauté universelle' from input i where i.name='MATRIM';insert into input_val(value, input_id, title) select '4', i.id, 'Régime légal' from input i where i.name='MATRIM';insert into input(name) values('ImmoYou');insert into input(name) values('ImmoCommu');insert into input(name) values('CashYou');insert into input(name) values('CashCommu');insert into input(name) values('GoodsYou');insert into input(name) values('GoodsCommu');insert into input(name) values('DebtYou');insert into input(name) values('DebtCommu');insert into input(name) values('Lfrom');insert into input_val(value, input_id, title) select '1', i.id, 'calculez votre capacité d\'emprunt' from input i where i.name='Lfrom';insert into input_val(value, input_id, title) select '2', i.id, 'connaître le montant de vos mensualités' from input i where i.name='Lfrom';insert into input(name) values('VI');insert into input(name) values('VM');insert into input(name) values('BirthYear');insert into input(name) values('IRvalue');insert into input(name) values('ISFvalue');insert into input(name) values('OBJ');insert into input_val(value, input_id, title) select '1', i.id, 'Vous constituer un patrimoine en toute sécurité' from input i where i.name='OBJ';insert into input_val(value, input_id, title) select '2', i.id, 'Préparer votre retraite' from input i where i.name='OBJ';insert into input_val(value, input_id, title) select '3', i.id, 'Diversifier votre patrimoine' from input i where i.name='OBJ';insert into input_val(value, input_id, title) select '4', i.id, 'Donner de la performance à vos investissements' from input i where i.name='OBJ';
insert into result(name) values('PART_NOCHILD');insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART_NOCHILD';insert into result_val(value, result_id) select '2', r.id from result r where r.name='PART_NOCHILD';insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART_NOCHILD';insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART_NOCHILD';
insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART_NOCHILD' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (  (i.name='F' and iv.value='1')  );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2' and r.name='PART_NOCHILD' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (  (i.name='F' and iv.value='2')  );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART_NOCHILD' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (  (i.name='F' and iv.value='3')  );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART_NOCHILD' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (  (i.name='F' and iv.value='4')  );
insert into result(name) values('PART');insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '2', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '2.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '3.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '4.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '5.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '6.5', r.id from result r where r.name='PART'; insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='0')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='1')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='2')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='3.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='3')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='4.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='4')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='5.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='5')    or (i.name='F' and iv.value='1')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='6.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='6')    or (i.name='F' and iv.value='1')     );insert into result_val(value, result_id) select '2', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '2.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '3', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '4', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '6', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '7', r.id from result r where r.name='PART'; insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='0')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='1')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='3' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='2')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='4' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='3')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='4')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='6' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='5')    or (i.name='F' and iv.value='2')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='7' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='6')    or (i.name='F' and iv.value='2')     );insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '1.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '2', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '3', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '4', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '6', r.id from result r where r.name='PART'; insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='0')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='1')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='2')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='3' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='3')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='4' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='4')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='5')    or (i.name='F' and iv.value='3')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='6' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='6')    or (i.name='F' and iv.value='3')     );insert into result_val(value, result_id) select '1', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '2.5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '3', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '4', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '5', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '6', r.id from result r where r.name='PART';insert into result_val(value, result_id) select '7', r.id from result r where r.name='PART'; insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='1' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='0')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='2.5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='1')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='3' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='2')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='4' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='3')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='5' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='4')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='6' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='5')    or (i.name='F' and iv.value='4')     );insert into value_assoc(resultval_id, inputval_id) select rv.id, iv.id from (select _rv.* from result_val _rv inner join result r on r.id=_rv.result_id where _rv.value ='7' and r.name='PART' and not exists   (select * from value_assoc va where va.resultval_id=_rv.id) limit 0,1) as rv inner join input_val iv inner join input i on i.id=iv.input_id where (       (i.name='NBCHILD' and iv.value='6')    or (i.name='F' and iv.value='4')     );



