[英]Date compatible Function from Oracle to Postgres
我正在尝试将以下定义转换为Postgres。
当前的Oracle代码:
PROCEDURE Run_All (inDate DATE DEFAULT SYSDATE) IS
在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))
但是仍然会引发如下错误:
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
什么是正确的转换方式,我在Postgres中缺少什么吗? 任何更新是绝对赞赏!
该错误不在显示的函数部分中,而是在SELECT
语句中函数主体的第13行中。
您的函数签名应该可以工作,但是如果您需要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.