当前位置:网站首页>Henkel database custom operator '! ~~'

Henkel database custom operator '! ~~'

2022-06-21 20:35:00 51CTO

Henkel database

Catalog

Environmental Science

Document purpose

Details

Environment system platform :Microsoft Windows (64-bit) 10 edition :5.6.5 Document purpose

Solve problems in the application SQL Statements use !~~ When matching operators , Mistakes encountered :

      
      
ERROR: 42883: operator does not exist: integer !~~ integer
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  • 1.
  • 2.


Details

One , Test preparation

Create tables and insert data :

      
      
create TABLE oper_test(first_num int);
insert into oper_test values(234),(446),(467);
  • 1.
  • 2.


Two , Test the query

      
      
select (446 !~~ first_num) newlist from oper_test;
  • 1.

 Henkel database custom operator

3、 ... and , Solution : Custom operators

      
      
CREATE OR REPLACE FUNCTION hgdb_catalog.intnlike(integer,integer)
RETURNS boolean AS $$
select $1::varchar !~~ $2::varchar;
$$
LANGUAGE sql strict;
ALTER FUNCTION intnlike(integer, integer)
OWNER TO highgo;
COMMENT ON FUNCTION intnlike(integer,integer) IS 'implementation of !~~ operator';create operator hgdb_catalog.!~~(
procedure = hgdb_catalog.intnlike,
leftarg = integer,
rightarg = integer
);
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.


Four , Query again

 Henkel database custom operator

The related documents

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211836364540.html