[英]Date compatible Function from Oracle to Postgres
I am trying to convert the below definition to Postgres. 我正在尝试将以下定义转换为Postgres。
Current Oracle code: 当前的Oracle代码:
PROCEDURE Run_All (inDate DATE DEFAULT SYSDATE) IS
In Postgres I used different versions: 在Postgres中,我使用了不同的版本:
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? 什么是正确的转换方式,我在Postgres中缺少什么吗? Any update is absolutely appreciated!
任何更新是绝对赞赏!
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. 该错误不在显示的函数部分中,而是在
SELECT
语句中函数主体的第13行中。
Your function signatures should work, but if you need the hour-to-second part of the Oracle DATE
, the perfect translation would be: 您的函数签名应该可以工作,但是如果您需要Oracle
DATE
的小时部分,那么完美的翻译应该是:
CREATE FUNCTION ssp2_pcat.gen_fios_xml$run_all
(indate timestamp(0) without time zone DEFAULT localtimestamp(0))
问题未解决?试试以下方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.