public inbox for [email protected]  
help / color / mirror / Atom feed
From: Subramanian,Ramachandran <[email protected]>
To: Laurenz Albe <[email protected]>
To: [email protected] <[email protected]>
Subject: AW: How to surround a selected value with double quotes?
Date: Mon, 22 Jun 2026 08:55:48 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

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: [email protected]
www.alte-leipziger.de
www.hallesche.de



-----Urspr眉ngliche Nachricht-----
Von: Laurenz Albe <[email protected]> 
Gesendet: Montag, 22. Juni 2026 10:26
An: Subramanian,Ramachandran IT-md-db <[email protected]>; [email protected]
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


view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: AW: How to surround a selected value with double quotes?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox