set - sqlite: can a db-name, table-name, column-name be an expression? -
i want fill sql-table update-function , choosing columns in expression this:
update marks set (select name students id='1')='aaa' subject='math';
to explain simply. i'd use expression column-name in trigger create relational table value value using set operator.
table students: id name 1 max 2 joe 3 jim table marks: subject max joe jim math aaa b c sport null null
in case phyton script fills table 'temps' row row sensor readings, 'sensorid' , 'timestamp'. lookup table 'sensors' can tell 'sensorname' according each 'sensorid'. trigger shall automatically fill pivot table 't1table' timestamp of zeroed seconds substr(new.timestamp,1,17)||'00'
.
timestamp t1 t2 t3 2015-01-01 12:35:00 23.5 22.3 null
the source code this:
create trigger insert_t1 after insert on temps begin insert or ignore t1table(timestamp) values(substr(new.timestamp,1,17)||'00'); update t1table set (select sensorname sensors sensors.sensorid=new.sensorid)= round(new.temperature,1) timestamp=substr(new.timestamp,1,17)||'00'; end;
unfortunately doesn't work like, error message
error: near "(": syntax error
it seems set operator expects hard coded entry. https://www.sqlite.org/lang_update.html
Comments
Post a Comment