0

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:

  1. CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
       (indate timestamp(0) DEFAULT CURRENT_DATE)
    
  2. CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
       (indate timestamp without timezone DEFAULT ('now'::text)::date)
    
  3. CREATE OR REPLACE FUNCTION ssp2_pcat.gen_fios_xml$run_all
       (indate date DEFAULT ('now'::text)::date)
    
  4. 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!

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

2 Comments

Ok, Really appreciate your time but Still the same error,! What can be the right signature that I can use here for running the Function Sirr.?
Thanks for your time in looking into this Laurenz,you are right, its a datatype mismatch in a variable in the source code that caused the error!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.