请帮我解决这个错误。
CREATE OR REPLACE FUNCTION MYCURSOR () RETURNS VARCHAR AS $$
declare
cur1 refcursor;
col_name varchar (10) ;
hstoredata hstore;
BEGIN
col_name = 'id';
OPEN cur1 FOR execute('select * from datas.tb where id =2');
loop
fetch cur1 into hstoredata;
if not found then
exit ;
end if;
Raise Notice '%',hstoredata -> col_name ;
end loop;
close cur1;
return 'r';
END;
$$ LANGUAGE plpgsql
当我尝试执行这个查询时,它显示了以下错误:
错误: 字符串意外结束 上下文: PL/pgSQL函数"mycursor"的第15行FETCH
********** 错误 **********
错误: 字符串意外结束 SQL状态: XX000 上下文: PL/pgSQL函数"mycursor"的第15行FETCH
cur1 refcursor; var1 varchar (10) ; hstoredata hstore; r record; alert_mesg VARCHAR(2000) := '';
BEGIN var1 = 'id'; OPEN cur1 FOR execute('select * from datas.tb where id =2'); loop fetch cur1 into r; if not found then exit ; end if; select hstore(r) into hstoredata;Raise Notice '%',hstoredata->'id'; end loop; close cur1; return alert_mesg; END; $$ LANGUAGE plpgsql - user2797756