CREATE OR REPLACE FUNCTION sp_insert_nike_mapping_code ( shopId bigint ) RETURNS VOID AS $body$
BEGIN
insert into temp_t_so_sales_order_push(so_code,seq)
SELECT so_code,nextval('s_t_so_sales_order_push_code') from (
SELECT so_code from t_so_sales_order_push where sync_status = 0 group by so_code
);
update t_so_sales_order_push pu
set code = (
SELECT temp.seq from temp_t_so_sales_order_push temp
where temp.so_code = pu.so_code and pu.shop_id = shopId and pu.sync_status = 0
)
where exists(
SELECT 1 from temp_t_so_sales_order_push temp
where temp.so_code = pu.so_code and pu.shop_id = shopId and pu.sync_status = 0
);
END
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;
当我执行上述代码时,出现了语法错误:FROM子查询必须有别名。 [Err] ERROR: FROM子查询必须有别名 LINE 5:...ELECT so_code,nextval('s_t_so_sales_order_push_code') from ( ^ HINT:例如,FROM(SELECT ...)[AS] foo。 有人能帮我吗?