Search code examples
postgresqlamazon-web-servicesaws-sct

Current setting in postgresql


I'm converting oracle to postgresql using AWS SCT tool.

I found the following line in one of function:

select (CLOCK_TIMESTAMP() AT TIME ZONE COALESCE(CURRENT_SETTING('aws_oracle_ext.tz', TRUE), 'UTC'))::TIMESTAMP(0)

Is there any other alternative of this setting aws_oracle_ext.tz in postgresql? I just want to remove dependency of all the extension of aws aws_oracle_ext.

Can I use the following one?

select (CLOCK_TIMESTAMP() AT TIME ZONE COALESCE(CURRENT_SETTING(now()::text, TRUE), 'UTC'))::TIMESTAMP(0)


Solution

  • That looks silly (besides, it is not Oracle code).

    • If you want the wall clock time in your session time zone, use

      SELECT clock_timestamp()::timestamp
      
    • If you want the transaction timestamp, use

      SELECT localtimestamp