[英]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.