1 CREATE DATABASE IF NOT EXISTS `meteo` /*!40100 DEFAULT CHARACTER SET utf8 */;
3 -- MySQL dump 10.13 Distrib 5.5.35, for debian-linux-gnu (i686)
5 -- Host: estia Database: meteo
6 -- ------------------------------------------------------
7 -- Server version 5.5.35-0ubuntu0.13.10.2
9 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
10 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
11 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
12 /*!40101 SET NAMES utf8 */;
13 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
14 /*!40103 SET TIME_ZONE='+00:00' */;
15 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
16 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
17 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
18 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
21 -- Dumping routines for database 'meteo'
23 /*!50003 DROP FUNCTION IF EXISTS `unitconv` */;
24 /*!50003 SET @saved_cs_client = @@character_set_client */ ;
25 /*!50003 SET @saved_cs_results = @@character_set_results */ ;
26 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
27 /*!50003 SET character_set_client = utf8 */ ;
28 /*!50003 SET character_set_results = utf8 */ ;
29 /*!50003 SET collation_connection = utf8_general_ci */ ;
30 /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
31 /*!50003 SET sql_mode = '' */ ;
33 CREATE DEFINER=`admin`@`%` FUNCTION `unitconv`(pValue float, pFromUnit integer, pToUnit integer) RETURNS float
37 if pFromUnit=pToUnit then
40 select u.a,u.b,u.c into a,b,c from unit_conv u where from_unit=pFromUnit and to_unit=pToUnit;
42 set result = (pValue+a)*b+c;
47 /*!50003 SET sql_mode = @saved_sql_mode */ ;
48 /*!50003 SET character_set_client = @saved_cs_client */ ;
49 /*!50003 SET character_set_results = @saved_cs_results */ ;
50 /*!50003 SET collation_connection = @saved_col_connection */ ;
51 /*!50003 DROP PROCEDURE IF EXISTS `submit_value` */;
52 /*!50003 SET @saved_cs_client = @@character_set_client */ ;
53 /*!50003 SET @saved_cs_results = @@character_set_results */ ;
54 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
55 /*!50003 SET character_set_client = utf8 */ ;
56 /*!50003 SET character_set_results = utf8 */ ;
57 /*!50003 SET collation_connection = utf8_general_ci */ ;
58 /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
59 /*!50003 SET sql_mode = '' */ ;
61 CREATE DEFINER=`admin`@`%` PROCEDURE `submit_value`(pSType varchar(32),pSID varchar(32),pParam varchar(32),pValue float)
66 select max(id) into lSTID from sensor_types where st_name=pSType;
67 if lSTID is not null then
68 select max(id) into lSID from sensors where st_id=lSTID and s_id=pSID;
69 if lSID is not null then
70 select max(id) into lSTPID from st_parameters where st_id=lSTID and st_name=pParam;
71 if lSTPID is not null then
72 insert into sensor_values(sensor_id,parameter_id,timestamp,value)
73 values(lSID,lSTPID,current_timestamp(),pValue);
79 /*!50003 SET sql_mode = @saved_sql_mode */ ;
80 /*!50003 SET character_set_client = @saved_cs_client */ ;
81 /*!50003 SET character_set_results = @saved_cs_results */ ;
82 /*!50003 SET collation_connection = @saved_col_connection */ ;
83 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
85 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
86 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
87 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
88 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
89 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
90 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
91 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
93 -- Dump completed on 2014-03-17 20:31:48