Postgresql plpgsql过程中返回错误的concat_ws没有结果数据的目标

Postgresql plpgsql过程中返回错误的concat_ws没有结果数据的目标,postgresql,stored-procedures,plpgsql,Postgresql,Stored Procedures,Plpgsql,我是plpgsql新手,现在已接近我想要做的事情: create or replace function shop_apply_search_filters( price_min integer default null, price_max integer default null, ecom_id integer default null, cat_1 text default null, cat_2 text default null) r

我是plpgsql新手,现在已接近我想要做的事情:

create or replace function shop_apply_search_filters(
    price_min integer default null, 
    price_max integer default null, 
    ecom_id  integer default null, 
    cat_1 text default null, 
    cat_2 text default null)
returns text as
$$
BEGIN
    IF cat_1 = '' THEN
        cat_1 = null;
    END IF;

    IF cat_2 = '' THEN
        cat_2 = null;
    END IF;

    select concat_ws(
        ' and ',
        'price < '      || price_min,
        'price > '      || price_max,
        'ecom_id = '    || ecom_id,
        'category_1 = ' || cat_1,
        'category_2 = ' || cat_2
    ) AS filters;
END;
$$
LANGUAGE PLPGSQL;

我不确定需要更改什么才能使其正常工作

您需要
返回结果

RETURN 
    concat_ws(
        ' and ',
        'price < '      || price_min,
        'price > '      || price_max,
        'ecom_id = '    || ecom_id,
        'category_1 = ' || cat_1,
        'category_2 = ' || cat_2
    );
返回
海螺(
"及",,
“价格<”| |价格|最低,
“价格>”| |价格|最大值,
“ecom_id=”|| ecom_id,
“类别| 1=”|类别| 1,
“类别2=”||类别2
);

您需要
返回结果

RETURN 
    concat_ws(
        ' and ',
        'price < '      || price_min,
        'price > '      || price_max,
        'ecom_id = '    || ecom_id,
        'category_1 = ' || cat_1,
        'category_2 = ' || cat_2
    );
返回
海螺(
"及",,
“价格<”| |价格|最低,
“价格>”| |价格|最大值,
“ecom_id=”|| ecom_id,
“类别| 1=”|类别| 1,
“类别2=”||类别2
);