postgresql 错误:函数 regexp_like(字符变化,未知)不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14342489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:44:00  来源:igfitidea点击:

ERROR: function regexp_like(character varying, unknown) does not exist

sqlpostgresql

提问by roykasa

I have this sql query that i am writing in postgres.

我有我在 postgres 中编写的这个 sql 查询。

select  to_char(calldate,'yyyymm') as month,min(calldate) as start_time,max(calldate) as   end_time,
'Onnet' as destination,ceil(sum(callduration::integer/60) )as   total_minutes,round(sum(alltaxcost::integer) ,2)as revenue
from cdr_data 
 where callclass ='008' and callsubclass='001'
 and callduration::integer >0
 and  regexp_like(identifiant,'^73')
 and bundleunits = 'Money'
 and inserviceresultindicator::integer in (0,5)
 and regexp_replace(callednumber,'^256','') ~ '^73'
 group by  to_char(calldate,'yyyymm') ,'Onnet'::text,to_char(calldate,'yyyymm') 

It gives me the following error:

它给了我以下错误:

[Err] ERROR:  function regexp_like(character varying, unknown) does not exist
LINE 9: and  regexp_regexp(identifiant,'^73')

I have tried replace with regexp_like with like, regexp_matches but they dont work. What could be the problem?

我试过用 regexp_like 替换,regexp_matches,但它们不起作用。可能是什么问题呢?

回答by dwurf

The PostgreSQL equivalent of regexp_like(identifiant,'^73')is identifiant ~ '^73'

PostgreSQL 的等价物regexp_like(identifiant,'^73')identifiant ~ '^73'

回答by Lokesh

Have you tried using SIMILAR TOoperator?

您是否尝试过使用SIMILAR TO运算符?

Some snippets from PostgreSQL documentation:

PostgreSQL 文档中的一些片段:

a. `select 'abc' SIMILAR TO '(a|d)%';`
b. `select 'def' SIMILAR TO '(a|b|c)%';`

Statement a returns t(true) as 'abc' starts with 'a' or 'd'. Statement b returns f(false) as 'def' doesn't start with either 'a' or 'b' or 'c'.

语句 a 返回t(true),因为 'abc' 以 'a' 或 'd' 开头。语句 b 返回f(false),因为 'def' 不以 'a' 或 'b' 或 'c' 开头。