diff --git a/fhem/contrib/DS_Starter/93_DbRep.pm b/fhem/contrib/DS_Starter/93_DbRep.pm
index d799c5674..5c86adb6e 100644
--- a/fhem/contrib/DS_Starter/93_DbRep.pm
+++ b/fhem/contrib/DS_Starter/93_DbRep.pm
@@ -57,7 +57,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Versions History intern
our %DbRep_vNotesIntern = (
- "8.10.0" => "19.01.2019 sqlCmd may input SQL session variables, Forum:#96082",
+ "8.10.0" => "19.01.2019 sqlCmd, dbValue may input SQL session variables, Forum:#96082 ",
"8.9.10" => "18.01.2019 fix warnings Malformed UTF-8 character during importFromFile, Forum:#96056 ",
"8.9.9" => "06.01.2019 diffval_DoParse: 'ORDER BY TIMESTAMP' added to statements Forum:https://forum.fhem.de/index.php/topic,53584.msg882082.html#msg882082",
"8.9.8" => "27.11.2018 minor fix in deviceRename, commandref revised ",
@@ -131,7 +131,7 @@ our %DbRep_vNotesIntern = (
# Versions History extern:
our %DbRep_vNotesExtern = (
- "8.10.0" => "19.01.2019 In sqlCmd you may now take over SQL session variables like \"SET \@open:=NULL,\@closed:=NULL; SELECT ...\", Forum:#96082",
+ "8.10.0" => "19.01.2019 In commands sqlCmd, dbValue you may now use SQL session variables like \"SET \@open:=NULL,\@closed:=NULL; SELECT ...\", Forum:#96082",
"8.9.0" => "07.11.2018 new command set delDoublets added. This command allows to delete multiple occuring identical records. ",
"8.8.0" => "06.11.2018 new attribute 'fastStart'. Usually every DbRep-device is making a short connect to its database when "
."FHEM is restarted. When this attribute is set, the initial connect is done when the DbRep-device is doing its "
@@ -5649,7 +5649,7 @@ sub sqlCmd_DoParse($) {
$rt = $rt.",".$brt;
- return "$name|$rowstring|$opt|$sql|$nrows|$rt|$err";
+ return "$name|$rowstring|$opt|$cmd|$nrows|$rt|$err";
}
####################################################################################################
@@ -9973,6 +9973,27 @@ sub DbRep_dbValue($$) {
Log3 ($name, 4, "DbRep $name - -------- New selection --------- ");
Log3 ($name, 4, "DbRep $name - Command: dbValue");
Log3 ($name, 4, "DbRep $name - SQL execute: $sql");
+
+ # split SQL-Parameter Statement falls mitgegeben
+ # z.B. SET @open:=NULL, @closed:=NULL; Select ...
+ my $set;
+ if($cmd =~ /^SET.*;/i) {
+ $cmd =~ m/^(SET.*?;)(.*)/i;
+ $set = $1;
+ $sql = $2;
+ }
+
+ if($set) {
+ Log3($name, 4, "DbRep $name - Set SQL session variables: $set");
+ eval {$dbh->do($set);}; # @\RB = Resetbit wenn neues Selektionsintervall beginnt
+ }
+ if ($@) {
+ $err = $@;
+ Log3 ($name, 2, "DbRep $name - $err");
+ ReadingsSingleUpdateValue ($hash, "errortext", $err, 1);
+ ReadingsSingleUpdateValue ($hash, "state", "error", 1);
+ return ($err);
+ }
# SQL-Startzeit
my $st = [gettimeofday];
@@ -11314,6 +11335,8 @@ return;
"allowDeletion" has to be set for security reason.
The statement doesn't consider limitations by attributes "device", "reading", "time.*"
respectively "aggregation".
+ This command also accept the setting of SQL session variables like "SET @open:=NULL,
+ @closed:=NULL;".
If the attribute "timestamp_begin" respectively "timestamp_end"
is assumed in the statement, it is possible to use placeholder "§timestamp_begin§" respectively
"§timestamp_end§" on suitable place.
@@ -11336,6 +11359,25 @@ return;