| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | Igor Korot <ikorot01(at)gmail(dot)com> |
| Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Return trimmed string from the query |
| Date: | 2026-11-01 07:02:45 |
| Message-ID: | CAFj8pRD0UydbucRrMhCGBNrf4GyP5OS7K32r5EBCYVAam0cAdg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-odbc |
Hi
ne 1. 11. 2026 v 7:43 odesílatel Igor Korot <ikorot01(at)gmail(dot)com> 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 │
└────────────┴─────┘
(1 row)
regards
Pavel
>
> Thank you.
>
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Korot | 2026-11-01 07:17:10 | Return trimmed string from the query |
| Previous Message | Igor Korot | 2026-11-01 06:01:18 | Re: Connecting pg_attribute with pg_namespace |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Korot | 2026-11-01 07:17:10 | Return trimmed string from the query |
| Previous Message | M. Neumann - Prisma Computer | 2026-10-08 06:13:42 | Re: Fwd: Invalid byte sequence |