function - postgresql check session config setting availability -
i have sensor data table full of 'holes', data saved when changes on specified threshold.
| time stamp | value1 | value2 | | 2012-01-01 | 1 | | | 2012-01-02 | | 2 | | 2012-01-05 | | | | 2012-01-20 | | | | 2012-03-01 | 3 | 1 |
i need cross row calculations, holes in tables make impractical. solution create auxiliary function wrap related field, , use session parameter persistent variable. sth this:
create function wrap_data( data1 numeric(3,1) ) ... language plpgsql if data1 <> null execute 'set session app.data1 = $1;' using data1; end if; return current_setting('app.data1')::numeric(3,1) ...
it works before executing function, have initialized variables outside of function by:
set session app.data1 = 11.1;
or complain parameter not unrecognized.
i looking function ifparameterexist(), allow me check existence of variable without raising error inside plpgsql function.
Comments
Post a Comment