postgresql - 我能够创建一个函数但无法调用它
问题描述
我正在尝试在 postgres 中创建一个函数,成功执行了 CREATE 查询,但是当我尝试调用该函数时,出现错误。
CREATE OR REPLACE FUNCTION sp_generate_random_locations(
"nwclatitude" NUMERIC,
"nwclongitude" NUMERIC,
"seclatitude" NUMERIC,
"seclongitude" NUMERIC,
"type" TEXT,
"count" INTEGER,
"runid" TEXT
) RETURNS INT AS
$BODY$
DECLARE
counter INTEGER := 0 ;
id uuid := uuid_generate_v1();
responder_latitude FLOAT(5):= nwclatitude+(seclatitudenwclatitude)*RANDOM();
responder_longitude FLOAT(5):= nwclongitude+(seclongitudenwclongitude)*RANDOM();
BEGIN
LOOP
EXIT WHEN counter=count;
--some task
END LOOP;
END;
$BODY$
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = admin, pg_temp;
现在,如果我尝试使用以下命令调用该函数
SELECT aed_modeling.sp_generate_random_locations(“nwclatitude” := 54.42 ,”nwclongitude” := 10.05 ,”seclatitude” := 54.14, “seclongitude” := 10.48,”type” :=’mobile’ ,”count” :=4 ,”runid” := ‘94984cb0-5f69-4326-b492-34fb19c39fc3’);
但我收到以下错误
42883: function sp_generate_random_locations(“nwclatitude” => numeric, ”nwclongitude” => numeric, ”seclatitude” => numeric, “seclongitude” => numeric, ”type” => unknown, ”count” => integer, ”runid” => unknown) does not exist
我不知道我在这里缺少什么。请注意,使用的“runid”不是 uuid,我将其用作字符串。即使我输入变量“type”和“runid”::text
也不起作用。
解决方案
迟到的回应,是的,根据评论,问题在于不正确的双引号。复制粘贴问题。:-D
例如“nwclatitude” := 54.42 should be "nwclatitude" := 54.42
推荐阅读
- python - 使用 Python 在 JIRA 中使用受让人、观察者和附件创建新问题
- c# - WPF:如何为 ListView 创建自定义视图模式
- android - 如何在活动底部显示覆盖进度条
- python - 将字典项转换为 pandas 数据帧的行,其中键是元组,值是整数
- unoconv - `unoconv`没有将excel工作表的所有内容导出为pdf
- javascript - 展开所有并折叠所有可折叠手风琴物化 css
- laravel - 无法与主机 mail.veebimajutus.ee 建立 Laravel 连接 [不允许操作 #1]
- google-cloud-platform - 谷歌计算引擎:项目重置?
- python - Python tkinter 列表框数据类型和格式
- java - android错误'java.net.SocketException:套接字失败:EACCES(权限被拒绝)'