【问题标题】:function pg_catalog.btrim(numeric, unknown) does not exist while creating table创建表时函数 pg_catalog.btrim(numeric, unknown) 不存在
【发布时间】:2018-05-25 10:31:01
【问题描述】:

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

【问题讨论】:

    标签: postgresql azure azure-postgresql


    【解决方案1】:

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

    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;
    

    DEMO

    【讨论】:

    • 感谢您的回复,尽管我仍然遇到同样的错误。但我想通了。我没有使用修剪,而是使用了 trunc 函数,它运行良好。 CREATE TABLE ref_lab_cohort_level AS SELECT 队列,in​​itcap (TRIM (result_flag)) 作为 result_flag,TRUNC (cohort_level) 作为队列级别 FROM temp_labs_levels;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-13
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 2019-02-23
    相关资源
    最近更新 更多