0

psql code:

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;

In above code, trim is function of PostgreSQL for trimming but it gives an error as follows:

 function pg_catalog.btrim(numeric, unknown) does not exist
Sivabalan
  • 971
  • 2
  • 18
  • 43
Sachin
  • 35
  • 1
  • 1
  • 6

1 Answers1

0

Here is the workaround for your question, check out might be useful to you:

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;

Ouput:

select * from ref_lab_cohort_level;

DEMO

  • Thank you for replying although i still get the same error. But i figured it out. Instead of trim i used trunc function and it worked well. CREATE TABLE ref_lab_cohort_level AS SELECT cohort,initcap (TRIM (result_flag)) AS result_flag, TRUNC (cohort_level) AS cohort_level FROM temp_labs_levels; – Sachin May 27 '18 at 15:19