Re: Having issues inserting a string with a ' into a varchar column

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Sbob <sbob(at)quadratum-braccas(dot)com>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Having issues inserting a string with a ' into a varchar column
Date: 2022-04-15 18:16:31
Message-ID: CAKFQuwbzdZ38iZXN9Mp3PEt767b9h-C91evBtAWo8GD_oqatMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Friday, April 15, 2022, Sbob <sbob(at)quadratum-braccas(dot)com> wrote:
>
> I tried this : quote_ident ( 'Poker 5 card Hold'Em')
>
> but it still error's out
>
>
> I also tried : quote_literal('Poker 5 card Hold\'Em')
>
> but it also errors out:
>
>
You have the right idea you need to escape it. But guessing isn’t a good
method to figure out how.

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

You can’t use quote_* on a literal if you do not express the literal
correctly.

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kenny Bachman 2022-04-15 20:59:25 postgresql-14 slow query
Previous Message Sbob 2022-04-15 18:02:57 Re: Having issues inserting a string with a ' into a varchar column