RETURN result; 代码语言:txt 复制 函数的完整示例代码如下: 代码语言:sql 复制 CREATEORREPLACEFUNCTIONget_users()RETURNSTABLE(idINTEGER,nameVARCHAR(50),emailVARCHAR(50))AS$$DECLAREresult RECORD;BEGINSELECT*INTOresultFROMusers;RETURNQUERYSELECT*FROMresult;END;$$LANGUAGEplpgsql; ...
CREATE OR REPLACE FUNCTION skytf.func_test_result_query_single ( in_id integer) RETURNSSETOF varcharas $$ DECLARE v_rec RECORD; BEGIN return query ( (select name from test_result1 where id = in_id) union (select name from test_result2 where id = in_id) ); return; END; $$ LANGUA...
RETURNQUERY query;RETURNQUERYEXECUTEcommand-string[USING expression [, ...]]; 4|24.1 RETURN QUERY命令 将一条查询的结果追加到一个函数的结果集中。 CREATEORREPLACEFUNCTIONgetAllFoo2()RETURNSSETOF fooAS$$DECLAREr foo%rowtype;BEGINRETURNQUERYSELECT*FROMfooWHEREfooid>0;END$$ LANGUAGE PLPGSQL; 4|34.2...
id; return null; end; functionfunction; CREATE FUNCTION postgres=# create trigger tg1 before delete on t_ret for each row execute procedure tg_t_ret(); CREATE TRIGGER postgres=# delete from t_ret where id=1; NOTICE: 00000: tg1, id:1 LOCATION: exec_stmt_raise, pl_exec.c:2840 DELETE ...
pg_catalog.pg_get_function_result(p.oid) as "Result data type", pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types", CASE p.prokind WHEN 'a' THEN 'agg' WHEN 'w' THEN 'window' WHEN 'p' THEN 'proc' ELSE 'func' ...
Invalid indexes (less than 0 or greater than or equal to tg_nargs) result in a null value. A trigger function must return either NULL or a record/row value having exactly the structure of the table the trigger was fired for. 以plpgsql为例,触发器函数范例。 使用hstore 和触发器跟踪敏感数...
/* actual function, if above is a wrapper */ struct PlanState *lefttree; /* input plan tree(s) */ struct PlanState *righttree; List *subPlan; /* SubPlanState nodes in my expressions */ TupleDesc ps_ResultTupleDesc; /* node's return type */ TupleTableSlot *ps_ResultTupleSlot; /*...
* to root->join_info_list for any outer joins appearing in the query tree. * Return a "joinlist" data structure showing the join order decisions * that need to be made by make_one_rel(). * * The "joinlist" result is a list of items that are either RangeTblRef ...
RETURN { variable_name | value } END; LANGUAGE plpgsql;function_name:指定函数的名称。[OR REPLACE]:是可选的,它允许修改/替换现有函数。DECLARE:定义参数(参数名写在前面 类型写在后面)。BEGIN~END: 在中间写方法主体。RETURN:指定要从函数返回的数据类型(它可以是基础,复合或域类型,或者也可以引用表列的...
PL/pgSQL RETURN QUERY支持并行计算 场景: 数据分析类业务 价值: 在PL/pgSQL函数内使用return query返回结果时支持query的并行计算来提升性能 DEMO: createorreplacefunctionxx...returnqueryselectxx from xx ...-- 这里到select xx query可以支持并行计算 刷新...