对了几遍好像和你这个差别不大,但是执行就报错了,说return query这个语法有问题。
drop FUNCTION hermes_reward_user; create or replace function hermes_reward_user(block_height NUMERIC) returns table (block_height NUMERIC, action_hash text, amount NUMERIC, recipient text, type text) as $$ begin return query select block_height, act_hash as action_hash, amount, owner_address as recipient, 'bucket' as type from staking_actions WHERE sender in ('io12mgttmfa2ffn9uqvn0yn37f4nz43d248l2ga85', 'io1lhukp867ume3qn2g7cxn4e47pj0ugfxeqj7nm8', 'io1h49cfw0zcj63chk6awu08u6xem8kpr350r5p57', 'io1unvkgm98ma3r2fnfrhep24arjxf6kc8stx0nuc') and act_type = 'DepositToStake' and block_height > $1 union all select block_height, action_hash, amount, recipient, 'transfer' as type from block_action where sender in ('io12mgttmfa2ffn9uqvn0yn37f4nz43d248l2ga85','io1lhukp867ume3qn2g7cxn4e47pj0ugfxeqj7nm8') and action_type = 'transfer' and block_height > $1
union all
select block_height, action_hash, amount, recipient, 'transfer' as type from block_receipt_transactions where sender = 'io16y9wk2xnwurvtgmd2mds2gcdfe2lmzad6dcw29' and type = 'execution' and block_height > $1 ;
end;
$$ language sql;
要在函数计算中执行 SQL 函数,建议使用 MySQL 的语法。以下是一个示例,您可以参考以下代码来创建类似的 MySQL 函数:
drop function if exists hermes_reward_user; create function hermes_reward_user(block_height FLOAT) returns table(block_height FLOAT, action_hash text, amount FLOAT, recipient text, type text) as begin return select block_height, act_hash as action_hash, amount, owner_address as recipient, 'bucket' as type from staking_actions WHERE sender in ('io12mgttmfa2ffn9uqvn0yn37f4nz43d248l2ga85', 'io1lhukp867ume3qn2g7cxn4e47pj0ugfxeqj7nm8', 'io1h49cfw0zcj63chk6awu08u6xem8kpr350r5p57', 'io1unvkgm98ma3r2fnfrhep24arjxf6kc8stx0nuc') and act_type = 'DepositToStake' and block_height > block_height union all select block_height, action_hash, amount, recipient, 'transfer' as type from block_action where sender in ('io12mgttmfa2ffn9uqvn0yn37f4nz43d248l2ga85','io1lhukp867ume3qn2g7cxn4e47pj0ugfxeqj7nm8') and action_type = 'transfer' and block_height > block_height union all select block_height, action_hash, amount, recipient, 'transfer' as type from block_receipt_transactions where sender = 'io16y9wk2xnwurvtgmd2mds2gcdfe2lmzad6dcw29' and type = 'execution' and block_height > block_height; end; 做出改动后,您可以尝试重新上传该函数,并在函数计算中进行测试
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
PolarDB 分布式版 (PolarDB for Xscale,简称“PolarDB-X”) 是阿里云自主设计研发的高性能云原生分布式数据库产品,为用户提供高吞吐、大存储、低延时、易扩展和超高可用的云时代数据库服务。