You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
4.7 KiB

3 years ago
  1. DO $$
  2. DECLARE
  3. idformsoriginsinserted bigint;
  4. idformsinserted bigint;
  5. idfieldsinserted bigint;
  6. BEGIN
  7. SELECT id FROM formsorigins INTO idformsoriginsinserted WHERE name = 'WP6.MobileApp' and active = 1;
  8. --BEGIN FLOODZONES_FORM
  9. INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) values (idformsoriginsinserted, "FLOODZONES_FORM", "Flood Zones", "Flood Zones Form", DateTime(), 1)
  10. RETURNING id INTO idformsinserted;
  11. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  12. SELECT fdt.id, 'id', 'id From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'integer'
  13. RETURNING id INTO idfieldsinserted;
  14. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  15. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  16. SELECT fdt.id, 'description', 'description From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'text'
  17. RETURNING id INTO idfieldsinserted;
  18. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  19. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  20. SELECT fdt.id, 'Images', 'Images From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'text'
  21. RETURNING id INTO idfieldsinserted;
  22. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  23. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  24. SELECT fdt.id, 'Latitude', 'Latitude From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'real'
  25. RETURNING id INTO idfieldsinserted;
  26. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  27. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  28. SELECT fdt.id, 'Longitude', 'Longitude From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'real'
  29. RETURNING id INTO idfieldsinserted;
  30. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  31. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  32. SELECT fdt.id, 'Passable', 'Passable From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'integer'
  33. RETURNING id INTO idfieldsinserted;
  34. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  35. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  36. SELECT fdt.id, 'Date', 'Date From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'text'
  37. RETURNING id INTO idfieldsinserted;
  38. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  39. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  40. SELECT fdt.id, 'Time', 'Time From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'text'
  41. RETURNING id INTO idfieldsinserted;
  42. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  43. INSERT INTO fields(idfieldsdatatypes, name, description, fillingclue, active)
  44. SELECT fdt.id, 'Address', 'Address From FloodZones Form', '', 1 FROM fieldsdatatypes fdt WHERE fdt.name = 'text'
  45. RETURNING id INTO idfieldsinserted;
  46. INSERT INTO formsfields(id, idforms, idfields, active) VALUES (DEFAULT, idformsinserted, idfieldsinserted, 1);
  47. --END FLOODZONES_FORM
  48. --BEGIN PLUVIOMETERS_FORM
  49. INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) values (idformsoriginsinserted, "PLUVIOMETERS_FORM", "Pluviometers", "Pluviometers Form", DateTime(), 1);
  50. --END PLUVIOMETERS_FORM
  51. --BEGIN RAIN_FORM
  52. INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) values (idformsoriginsinserted, "RAIN_FORM", "Rain", "Rain zones Form", DateTime(), 1);
  53. --END RAIN_FORM
  54. --BEGIN RIVERFLOOD_FORM
  55. INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) values (idformsoriginsinserted, "RIVERFLOOD_FORM", "River Flood", "River Flood Form", DateTime(), 1);
  56. --END RIVERFLOOD_FORM
  57. --BEGIN PLUVIOMETERS_REGISTRATION
  58. INSERT INTO forms(idformsorigins, code, name, description, dtcreation, active) values (idformsoriginsinserted, "PLUVIOMETERS_REGISTRATION", "Pluviometer registration", "Pluviometer registration", DateTime(), 1);
  59. --END PLUVIOMETERS_REGISTRATION
  60. END $$;