首页 > 解决方案 > 创建表时函数 pg_catalog.btrim(numeric, unknown) 不存在

问题描述

psql代码:

CREATE TABLE ref_lab_cohort_level
    AS
SELECT cohort,initcap (TRIM (result_flag)) AS result_flag,
       TRIM (cohort_level) AS cohort_level
FROM temp_labs_levels;

在上面的代码中,trim 是 PostgreSQL 的修剪功能,但它给出了如下错误:

 function pg_catalog.btrim(numeric, unknown) does not exist

标签: postgresqlazureazure-postgresql

解决方案


这是您的问题的解决方法,查看可能对您有用:

create table temp_labs_levels(c varchar(200));
insert into temp_labs_levels values ('   ABC    ');
insert into temp_labs_levels values ('IJK    ');
insert into temp_labs_levels values ('    XYZ');
insert into temp_labs_levels values ('Normal TEXT');

create table ref_lab_cohort_level
as
select c,
       trim(c) c_trimmed,
       initcap(trim(c)) c_trim_initcap 
from temp_labs_levels;

输出:

select * from ref_lab_cohort_level;

演示


推荐阅读