2017-05-11 166 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的错误猜测。 –