2017-05-11 226 views
0

我正在使用PostgreSQL上的表格返回函數(使用pgAdmin 4)。它曾經工作得很好,但由於某種原因,我得到試圖修改功能時,此錯誤消息:postgresql截斷字符串

ERROR: type "TABLE(id integer, id_scenario integer, date_valid timestamp wit" does not exist NOTICE: identifier "TABLE(id integer, id_scenario integer, date_valid timestamp without time zone, dni_q95 double precision, csp_forecast_q95 double precision, storage_q95 double precision)" will be truncated to "TABLE(id integer, id_scenario integer, date_valid timestamp wit"

我明白了一個標識符不能超過63個字節,所以我的代碼行被截斷。我會很感激,如果有人可以幫助我在這2個問題:

  1. 爲什麼這條線突然公認的標識?

  2. 如何解決這個問題,知道我需要返回所有這些列?

下面是函數體:

CREATE OR REPLACE FUNCTION public.csp_park_95(id_park integer) 
RETURNS SETOF "TABLE(id integer, id_scenario integer, date_valid 
timestamp without time zone, dni_q95 double precision, csp_forecast_q95 
double precision, storage_q95 double precision)" 
LANGUAGE 'sql' 
COST 100.0 
VOLATILE 
ROWS 1000.0 
AS $function$ 

-- irrelevant code 

$function$; 

ALTER FUNCTION public.csp_park_95(integer) 
OWNER TO "POC_kacare_admin"; 
+1

「*?爲什麼這條線突然公認的標識符」 *因爲雙引號是標識符:https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS –

回答

0

嘗試刪除雙引號作爲如下:

CREATE OR REPLACE FUNCTION public.csp_park_95(id_park integer) 
    RETURNS TABLE(id integer, id_scenario integer, date_valid 
    timestamp without time zone, dni_q95 double precision, csp_forecast_q95 
    double precision, storage_q95 double precision) 
    LANGUAGE 'sql' 
    COST 100.0 
    VOLATILE 
    ROWS 1000.0 
    AS $function$ 
    -- irrelevant code 
    $function$; 
+0

這不是pgAdmin中的錯誤。雙打引號用於識別。所以''TABLE(id整數,id_scenario整數,date_valid 沒有時區的時間戳,dni_q95雙精度,csp_forecast_q95 雙精度,storage_q95雙精度)**是**一個**名稱,不是名稱和參數列表。 –

+0

是的,我知道。但是,如果我理解正確的問題'「表(ID整數,id_scenario整數,date_valid時間戳無時區,dni_q95雙精度,csp_forecast_q95雙精度,storage_q95雙精度)」'是不是想要的,他說:_「2)如何爲了避免這個問題,知道我需要返回所有這些列?「_。 –

+0

無論如何,我編輯我的答案,以避免pgAdmin4的錯誤猜測。 –