数据库函数给出错误 - Postgresql [英] Database Function giving an error - Postgresql

查看:112
本文介绍了数据库函数给出错误 - Postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一些帮助,并得到以下代码:

   - 设置Solrid函数
CREATE OR REPLACE FUNCTION solrid(IN local_id INTEGER,OUT result TEXT)AS $$
DECLARE
database_id TEXT:='A';
BEGIN
results:= database_id || local_id :: TEXT;
END;
$$ LANGUAGE PLPGSQL;然而,当我在sqlfiddle中运行它说:


架构创建失败:错误:未绑定的美元引号字符串或
在$$ DECLARE database_id TEXT:='A'附近:


这个错误可能看起来很自我解释,但我不知道如何解决它。

解决方案

这个函数绝对没有问题,它是100%合法的。我在我的安装中测试了8.4和9.1。



必须有某种误解。这不能是触发错误消息的完全相同的代码。


I had some help on here and got the following code:

-- Setup Solrid Function
CREATE OR REPLACE FUNCTION solrid(IN local_id INTEGER, OUT result TEXT) AS $$
DECLARE
  database_id TEXT := 'A';
BEGIN
  result := database_id || local_id::TEXT;
END;
$$ LANGUAGE PLPGSQL;

However when I run it in sqlfiddle it says:

Schema Creation Failed: ERROR: unterminated dollar-quoted string at or near "$$ DECLARE database_id TEXT := 'A'":

This error may seem pretty self explanatory but I can't figure out the way to fix it. Would anyone mind shedding some light on this please?

解决方案

There is absolutely nothing wrong with this function, it is 100 % legit. I tested with 8.4 and 9.1 in my installation.

There must be some kind of misunderstanding. This cannot be exactly the same code that triggers the error message.

这篇关于数据库函数给出错误 - Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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