Reputation: 197
I am trying to convert the below definition to Postgres.
Current Oracle code:
PROCEDURE Run_All (inDate DATE DEFAULT SYSDATE) IS
In Postgres I used different versions:
CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate timestamp(0) DEFAULT CURRENT_DATE)
CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate timestamp without timezone DEFAULT ('now'::text)::date)
CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate date DEFAULT ('now'::text)::date)
CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate timestamp(0) DEFAULT CURRENT_TIMESTAMP::timestamp(0))
But still it's throwing an error as below:
ERROR: column "timestamp" does not exist
LINE 1: SELECT TIMESTAMP
^
QUERY: SELECT TIMESTAMP
CONTEXT: PL/pgSQL function "gen_fios_xml$run_all"(date) line 13 during statement block local variable initialization
SQL state: 42703
What would be the right way to convert, am I missing something in Postgres? Any update is absolutely appreciated!
Upvotes: 0
Views: 313
Reputation: 248225
The error is not in the part of the function that you are showing, it is in line 13 of the function body in a SELECT
statement.
Your function signatures should work, but if you need the hour-to-second part of the Oracle DATE
, the perfect translation would be:
CREATE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate timestamp(0) without time zone DEFAULT localtimestamp(0))
Upvotes: 1