开发者社区> 问答> 正文

postgresql:创建函数decode(args _bool)?报错

DECLARE
	length int2 = array_length(args, 1);
	index int2 = 2;
BEGIN
	-- 参数列表不允许低于数量3
	if 
		length < 3 
	then 
		raise exception '参数数量不能低于3';
	end if;
	
	-- 索引从2开始, 跳过被比较值
	while index < length
	loop
		if 
			-- 比较值与被比较值相等, 即返回数组中下一元素
			args[index] = args[1]
		then 
			return args[index + 1];
		end if;
		index = index + 2;
	end loop;
	
	if 
		length % 2 = 0
	then 
		-- 没有匹配, 返回默认值
		return args[length];
	end if;

	-- 同Oracle, 没有默认值返回为null
	return null;
end;

navciatc创建函数报错

伪函数作为返回类型,为什么在公司服务器postgresql就没有问题,而在我自己的postgresql就如上图的错误

展开
收起
爱吃鱼的程序员 2020-06-06 15:03:38 917 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>这种需要去命令行执行的</p>
    
                    
    
                        <div class='ref'><h4>引用来自“ville”的评论</h4><p>这种需要去命令行执行的</p>
    
    
                            到postgresql的命令行去执行
    
    2020-06-06 15:03:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖大会:开源 PolarDB 架构演进、关键技术与社区建设 立即下载
2023云栖大会:和客户一起玩转PolarDB新特性 立即下载
2023云栖大会:PolarDB for AI 立即下载

相关镜像