| From: | "Subramanian,Ramachandran" <ramachandran(dot)subramanian(at)alte-leipziger(dot)de> |
|---|---|
| To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org> |
| Subject: | AW: How to surround a selected value with double quotes? |
| Date: | 2026-06-22 08:55:48 |
| Message-ID: | a62288386ffc42dd9003313e172fa03c@alte-leipziger.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
Thank you so much!!! Yes I ment bash script.
QUOTE_IDENT() worked like black magic!!
Postgres puts quotes for the names that need them and no quotes for those that do not need them 😊 😊
LG
Ram
11657 | data | 5432 | "7464128"."rel_7464128_m2m_story_relatedProjects_project" | 8192
11655 | data | 5432 | "7464128"."rel_7464128_m2m_story_requiredStories_story" | 0
11527 | data | 5432 | catemplate_backup_version_250605_1756913256437."rel_1_m2m_companies_commercialContactPersons_persons" | 0
11527 | data | 5432 | catemplate_backup_version_250908_1760965502453."rel_1_m2m_companies_commercialContactPersons_persons" | 0
Freundliche Grüße
i. A. Ramachandran Subramanian
Zentralbereich Informationstechnologie
Alte Leipziger Lebensversicherung a.G.
Hallesche Krankenversicherung a.G.
Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814
Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
Wiltrud Pekarek, Udo Wilcsek
Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum
______________________
ALH Gruppe
Alte Leipziger-Platz 1, 61440 Oberursel
Tel.: +49 (6171) 66-4882
Fax: +49 (6171) 66-800-4882
E-Mail: ramachandran(dot)subramanian(at)alte-leipziger(dot)de
www.alte-leipziger.de
www.hallesche.de
-----Ursprüngliche Nachricht-----
Von: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Gesendet: Montag, 22. Juni 2026 10:26
An: Subramanian,Ramachandran IT-md-db <ramachandran(dot)subramanian(at)alte-leipziger(dot)de>; pgsql-novice(at)lists(dot)postgresql(dot)org
Betreff: Re: How to surround a selected value with double quotes?
On Mon, 2026-06-22 at 07:46 +0000, Subramanian,Ramachandran wrote:
> I wrote a script to analyze and run vacuum on tables that need it.
I assume you are talking about a bash script.
> Sadly at the time I wrote the script, I never expected a schema name
> to be pure numbers.
>
> So my Script does not work now.
>
> I want to add double quote marks to each schema name and table name select.
> I tried using the CONCAT function, but it does not work as I expected it to.
>
> I would be grateful if someone can help me understand the mistake I am making with the CONCAT.
You are a victim of (self-inflicted) SQL injection.
Just surrounding the schema name with double quotes is not enough.
What if the schema name itself contains a double quote?
You should use PostgreSQL's functions to properly quote an identifier.
With a shell script, I think your only choice is to use SQL:
#!/bin/bash
schema='12345 43'
table='tab"567'
quoted_schema=$(psql -Atq -v var="$schema" <<EOF SELECT quote_ident(:'var'); EOF
)
quoted_table=$(psql -Atq -v var="$table" <<EOF SELECT quote_ident(:'var'); EOF
)
sql="SELECT col FROM $quoted_schema.$quoted_table"
Yours,
Laurenz Albe
| From | Date | Subject | |
|---|---|---|---|
| Next Message | hubert depesz lubaczewski | 2026-06-22 10:09:29 | Re: How to surround a selected value with double quotes? |
| Previous Message | Laurenz Albe | 2026-06-22 08:26:24 | Re: How to surround a selected value with double quotes? |