čt 5. 11. 2026 v 3:56 odesílatel Igor Korot <[email protected]> napsal:
> Hi, > > On Sun, Nov 1, 2026 at 12:03 AM Pavel Stehule <[email protected]> > wrote: > > > > Hi > > > > ne 1. 11. 2026 v 7:43 odesílatel Igor Korot <[email protected]> napsal: > >> > >> hi, ALL, > >> Is there an option to return a trimmed string from the query? > >> > >> If I try to retrieve the char(10) from the table and the field only have > >> "abc", how to prevent the value to be returned as "abc "? > > > > > > no, there is not any option, you need to cast result value to varchar; > > > > (2026-11-01 07:57:03) postgres=# create table foo(a char(10)); > > CREATE TABLE > > (2026-11-01 08:01:49) postgres=# insert into foo values('abc'); > > INSERT 0 1 > > (2026-11-01 08:02:03) postgres=# select a, a::varchar from foo; > > ┌────────────┬─────┐ > > │ a │ a │ > > ╞════════════╪═════╡ > > │ abc │ abc │ > > └────────────┴─────┘ > > Sorry for a late reply. > > So does this mean that if I use varchar instead of char I will not > have this problem? > sure. char(n) type is "strange". It is designed for compatibility with old Cobol databases, and there is not any benefit for their usage today. Regards Pavel > > Thank you, > > > (1 row) > > > > regards > > > > Pavel > > > >> > >> > >> Thank you. > >> > >> >
