Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

"cast( data ->> 'temperature' as DOUBLE PRECISION)" is to find the 'temperature' in data and convert it to double format. Using the following SQL can make it more responsive ( just running once):



Code Block
languagesql
create or replace function cast_to_double(text) returns DOUBLE PRECISION as

...

Code Block
languagesql
 $$


begin
    -- Note the double casting to avoid infinite recursion.
    return cast($1::varchar as DOUBLE PRECISION);
exception
    when invalid_text_representation then
        return 0.0;
end;
$$ language plpgsql immutable;
create cast (text as DOUBLE PRECISION) with function cast_to_double(text);

...