Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 执行postgresql函数时出错_Function_Postgresql_Stored Procedures_Plpgsql - Fatal编程技术网

Function 执行postgresql函数时出错

Function 执行postgresql函数时出错,function,postgresql,stored-procedures,plpgsql,Function,Postgresql,Stored Procedures,Plpgsql,我有一个简单的功能: CREATE OR REPLACE FUNCTION soundavity.perform_search_by_serie_name( in_search_text text ) RETURNS bigint[] AS $BODY$ DECLARE match_id bigint[]; BEGIN SELECT id INTO match_id FROM soundavity.tv_serieslist_tbl where id IN (

我有一个简单的功能:

CREATE OR REPLACE FUNCTION soundavity.perform_search_by_serie_name( in_search_text   text )
RETURNS bigint[] AS

$BODY$

DECLARE 
match_id bigint[];  

BEGIN

SELECT id INTO match_id
FROM soundavity.tv_serieslist_tbl
where id IN (   
        SELECT id 
        FROM table
        WHERE to_tsvector('english', name) @@ to_tsquery('english', in_search_text)
        )
LIMIT 10;   


RETURN match_id;

END;
但是当我试着

select perform_search_by_serie_name('something');
Postgres返回:

ERROR:  array value must start with "{" or dimension information
CONTEXT:  PL/pgSQL function soundavity.perform_search_by_serie_name(text) line 8 at    SQL statement

错误在哪里?

'SELECT id'返回一组bigint而不是bigint数组。 试试这个:

DECLARE 
    match_id bigint[] = '{}';
    rid bigint;
BEGIN
    for rid in
        SELECT ... -- without INTO
    loop
        match_id:= array_append(match_id, rid);
    end loop;
RETURN match_id;

“SELECT id”返回bigint not bigint数组的集合。 试试这个:

DECLARE 
    match_id bigint[] = '{}';
    rid bigint;
BEGIN
    for rid in
        SELECT ... -- without INTO
    loop
        match_id:= array_append(match_id, rid);
    end loop;
RETURN match_id;