Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 使用Pl/pgsql插入到表中_Postgresql_Plpgsql - Fatal编程技术网

Postgresql 使用Pl/pgsql插入到表中

Postgresql 使用Pl/pgsql插入到表中,postgresql,plpgsql,Postgresql,Plpgsql,我尝试使用pl/pgsql将UUID值添加到表中。这是我的代码: CREATE OR REPLACE FUNCTION "Surrogate_gen"() RETURNS uuid AS $BODY$DECLARE uid UUID; BEGIN uid:=(select uuid_generate_v1()); INSERT INTO public.Surrogate_Table(wert) VALUES(uid); RAISE NOTICE 'My UUID is %',uid; re

我尝试使用pl/pgsql将UUID值添加到表中。这是我的代码:

CREATE OR REPLACE FUNCTION "Surrogate_gen"()
  RETURNS uuid AS
$BODY$DECLARE 
uid UUID;
BEGIN
uid:=(select uuid_generate_v1());
INSERT INTO public.Surrogate_Table(wert) VALUES(uid);
RAISE NOTICE 'My UUID is %',uid;
return uid;
END
$BODY$
如果我运行此代码,则会发生错误,并显示: 关系»公共。代理表«不存在

但是这个表存在于我的数据库中。我怎样才能解决这个问题?
谢谢

我猜您创建的代理表是这样的:

create table "Surrogate_Table" (...)
请注意表名周围的引号,还请注意错误消息是关于代理表的
subrogate\u
。PostgreSQL将所有不带引号的标识符折叠为小写,但您有一个大小写混合的表名。添加更多双引号以获得正确的大小写:

INSERT INTO public."Surrogate_Table"(wert) VALUES(uid);