PostgreSQL GOTO like关键字跳转到一个块 [英] PostgreSQL GOTO like keyword to jump to a block

查看:732
本文介绍了PostgreSQL GOTO like关键字跳转到一个块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PostgreSQL函数

I have a PostgreSQL function

CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS $$
BEGIN
IF i<0 THEN 
RETURN i + 1;
ELSE
  GOTO label1;
END IF
<<label1>>
RETURN null;
END;
$$ LANGUAGE plpgsql;

在此功能中,我必须转到标签1,但是GOTO关键字不起作用,您能否帮助我找到一种方法,使我能够从特定代码跳转到标签.

In this function I have to GOTO to a label1, but GOTO keyword is not working, can u please help me in getting the way from which I am able to jump from a particular code to label.

推荐答案

解决方法:

<<label>>
LOOP
   ...
   EXIT label WHEN i > 0;
   ...
   EXIT;
 END LOOP label;
 some;

但是我十年没用过-所以通常你做错了

But I didn't use it ten years - so usually you do some wrong

这篇关于PostgreSQL GOTO like关键字跳转到一个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆