Postgres (8.0.2., Redshift) SQL function definition, error "The cursor is not located inside a statement" -
i super noob in postgresql. need define func map: int --> datetime
after reading documentation i've come this:
create function fut(num integer) returns datetime -- convert unix time integer datetime timestamp $$ select timestamp 'epoch'+interval '1 second'*num; $$ language plpgsql; select fut(500);
but returns
the cursor not located inside statement!
could please point me doing wrong here?
as far knew redshift doesn't permit user-defined functions. yeah: http://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-features.html : user-defined functions , stored procedures. think you're plain out of luck.
a search redshift epoch timestamp or redshift to_timestamp
finds lots of other people have looked already:
- http://yiyujia.blogspot.com.au/2014/04/redshift-convert-integer-to-timestamp.html
- http://www.valkrysa.com/tech/2015/1/30/amazon-redshift-converting-unix-epoch-time-into-timestamps
etc.
the sensible answers rely on:
timestamp 'epoch' + myunixtime * interval '1 second '
which appear doing. best going get, because redshift not support user-defined functions.
Comments
Post a Comment