使用dblink和concat转义创建函数

时间:2019-06-10 12:05:00

标签: sql postgresql function select return

我正在使用postgreSQL(pgadmin 3)在选择中使用dblink和concat ESCAPE创建函数。

CREATE OR REPLACE FUNCTION public.crm_layout_1100()
  RETURNS TABLE (layout_1100 text)
  AS $func$
BEGIN
    RETURN QUERY
        SELECT * FROM dblink('CONNECTION STRING',
                             'SELECT ''RETURN_1'' ||E''\t''|| ''RETURN_2''') as link
                            (LAYOUT_1100 varchar);
    END;
$func$ 
LANGUAGE plpgsql;

当我执行脚本时,postgres中的结果是:

WARNING:  nonstandard use of escape in a string literal
LINE 8:                     'SELECT ''CUSTOMER_ID'' ||E''\t''|| ''RE...
                            ^
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
WARNING:  nonstandard use of escape in a string literal
LINE 8:                     'SELECT ''CUSTOMER_ID'' ||E''\t''|| ''RE...
                            ^
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.

Query returned successfully with no result in 13 msec.

上面的脚本只是我需要的示例,基本上是从表中返回“ VALUE_1” ESCAPE “ VALUE_2” ...

0 个答案:

没有答案