Using one of the hstore
constructor functions would probably be easier:
hstore(text[])
: construct an hstore from an array, which may be either a key/value array, or a two-dimensional array.
hstore(text[], text[])
: construct an hstore from separate key and value arrays.
So you could use one of these:
hstore(array['level', '1', 'last_collected', now()::text])
hstore(array[array['level', '1'], array['last_collected', now()::text]])
hstore(array['level', 'last_collected'], array['1', now()::text])
Keep in mind that hstore uses text
for both the keys and values so your timestamp will be a string. You might want to use to_char
instead of ::text
to convert your timestamp to a string, that will give you more control over the precision and format.
hstore(ARRAY['level', '1', 'last_collected', to_char(CURRENT_TIMESTAMP, 'HH12:MI:SS')]);