簡體   English   中英

從Oracle到Postgres的日期兼容功能

[英]Date compatible Function from Oracle to Postgres

我正在嘗試將以下定義轉換為Postgres。

當前的Oracle代碼:

PROCEDURE Run_All (inDate DATE DEFAULT SYSDATE) IS

在Postgres中,我使用了不同的版本:

  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)) 

但是仍然會引發如下錯誤:

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))

問題未解決?試試以下方法:

從Oracle到Postgres的日期兼容功能

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2023 STACKOOM.COM