Buenas tardes, en una función python que devuelve una tabla, ¿*cómo hago para agregar líneas al conjunto de resultados*? Suponiendo que el resultado de una consulta es una lista de diccionarios, intenté agregar un dicc a la lista, pero no funciona. Mi intento fue así: create or replace function fn_detalle(id integer) returns table(orderid integer, category text, title text) as $$ res = plpy.execute('select orderid,category,title from orderlines inner join products using (prod_id)where orderid = '+str(id)) dict={"orderid":123,"categgory":"prueba","title":"Título"} res.append(dict) return res $$ LANGUAGE plpython3u;
luego el llamado a la función así: select orderid,category,title from fn_detalle(16) y el error obtenido es: ERROR: AttributeError: 'PLyResult' object has no attribute 'append' CONTEXT: Traceback (most recent call last): PL/Python function "fn_detalle", line 4, in <module> res.append(dict) función PL/Python «fn_detalle» También probé utilizando contatenación de la siguietne manera: res=res+dict Pero obtengo otro error: ERROR: TypeError: unsupported operand type(s) for +: 'PLyResult' and 'dict' CONTEXT: Traceback (most recent call last): PL/Python function "fn_detalle", line 4, in <module> res=res+dict función PL/Python «fn_detalle»