英文:
postgres function error on Insert operation for object identifier types : SQL Error [42725]: ERROR: more than one operator named +
问题
Postgresql Insert statement on Objectidentifier datatype 'regoper' returns error 'SQL Error [42725]: ERROR: more than one operator named +' even though a single operator value is given
Hi, 我创建了一个用于Postgresql的所有对象标识符数据类型的表。DDL语句如下:
CREATE TABLE public.objectidentifiers (
pk int4 NOT NULL,
col_oid oid NULL,
col_regclass regclass NULL,
col_regcollation regcollation NULL,
col_regconfig regconfig NULL,
col_regdictionary regdictionary NULL,
col_regnamespace regnamespace NULL,
col_regoper regoper NULL,
col_regoperator regoperator NULL,
col_regproc regproc NULL,
col_regprocedure regprocedure NULL,
col_regrole regrole NULL,
col_regtype regtype NULL,
CONSTRAINT objectidentifiers PRIMARY KEY (pk)
);
其中public是模式名称,objectidentifiers是表名。
我正在尝试执行以下插入操作:
INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
'+',
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);
但是这会导致以下错误:
SQL查询执行期间发生错误
原因:
SQL错误 [42725]:ERROR: 存在多个名为 + 的运算符位置:114"
有人能告诉我插入语句中有什么问题吗?尽管我正在使用正确的数据类型值。
英文:
Postgresql Insert statement on Objectidentifier datatype 'regoper' returns error 'SQL Error [42725]: ERROR: more than one operator named +' even though a single operator value is given
Hi, I have a created a table for all Object Identifier data types of Postgresql. The DDL statement for the same is as follows :
CREATE TABLE public.objectidentifiers (
pk int4 NOT NULL,
col_oid oid NULL,
col_regclass regclass NULL,
col_regcollation regcollation NULL,
col_regconfig regconfig NULL,
col_regdictionary regdictionary NULL,
col_regnamespace regnamespace NULL,
col_regoper regoper NULL,
col_regoperator regoperator NULL,
col_regproc regproc NULL,
col_regprocedure regprocedure NULL,
col_regrole regrole NULL,
col_regtype regtype NULL,
CONSTRAINT objectidentifiers PRIMARY KEY (pk)
);
where public is the schema name and objectidentifiers is the table.
I am trying to execute this Insert Operation :
INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
'+',
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);
But this is giving the below error :
> Error occurred during SQL query execution
>
> Reason:<BR> SQL Error [42725]: ERROR: more than one operator named +
>
> Position: 114"
Can someone tell what is wrong in the Insert statement, even though I am using the right value for the data type
答案1
得分: 0
问题可能是因为PostgreSQL中的regoper
期望操作符对象标识符而不是操作符本身,所以我认为'+'触发了这个问题。
您可以使用pg_operator
系统目录表来查找+
的操作符ID。
INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
(SELECT oid FROM pg_operator WHERE oprname = '+'),
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);
英文:
the issue is probably because regoper
in postgres expects an operator object identifier instead of the operator itself so I think '+' is triggering the issue.
Instead you can use pg_operator
system catalog table to find the operator id for +
.
INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
(SELECT oid FROM pg_operator WHERE oprname = '+'),
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论