From 9a9b5befc963b32d91a85e14efb04d7ac4ca592f Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Fri, 2 Mar 2012 01:20:40 +0100 Subject: ebus-racket: use define instead of let --- ebus-racket/db.rkt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'ebus-racket/db.rkt') diff --git a/ebus-racket/db.rkt b/ebus-racket/db.rkt index 14817e5..9ebdfa9 100644 --- a/ebus-racket/db.rkt +++ b/ebus-racket/db.rkt @@ -22,16 +22,19 @@ ;; Get ID of sensor given by sensor-name ;; define sensor if needed (define (sensor-id sensor-name) - (let ([id (get-sensor-id sensor-name)]) - (cond ((void? id) (create-sensor-id sensor-id)) - (else id)))) + (define id (get-sensor-id sensor-name)) + (cond ((void? id) (create-sensor-id sensor-id)) + (else id))) (define (insert sensor-name value-float value-int value-string) - (let ([sensor-id (sensor-id sensor-name)] - [type (cond ((not (void? value-string)) "string") + (define sensor-id (sensor-id sensor-name)) + (define type (cond ((not (void? value-string)) "string") ((not (void? value-float)) "float") - ((not (void? value-int)) "int"))]) - (db:query-exec (string-append "INSERT INTO value(timestamp, sensor_id, type, value_float, value_int, value_string) " - "VALUES (now(), $1, $2, $3, $4, $5)") - sensor-id type value-float value-int value-string))) + ((not (void? value-int)) "int"))) + (db:query-exec (string-append "INSERT INTO value(timestamp, sensor_id, type, value_float, value_int, value_string) " + "VALUES (now(), $1, $2, $3, $4, $5)") + sensor-id type value-float value-int value-string)) + +(provide + (prefix-out db- insert)) -- cgit v1.2.1