Re: How to ensure column names are double quoted while using execute format when building a stored procedure?

From: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to ensure column names are double quoted while using execute format when building a stored procedure?
Date: 2021-12-16 21:33:25
Message-ID: CA+i5Jwa5ZyvWKyrCgfUwO937110VHVTtQwNz52qZMjw-hnLgUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I did make it to work and have been experimenting on a number of ways. But
it just does not produce expected results.

Regards,

David

On Thu, 16 Dec 2021 at 21:25, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> On Thu, Dec 16, 2021 at 2:11 PM Shaozhong SHI <shishaozhong(at)gmail(dot)com>
> wrote:
>
>> When I used SQL identifier, it stopped working. The command line gets
>> interpreted as following:
>>
>> insert into stats select "1" as id, 'count of nulls in
>> "UNIQUE_REFERENCE_NUMBER"' as checks, count("""UNIQUE_REFERENCE_NUMBER""")
>> from points_of_interest."pointx_v2_National_Coverage_Sep21" where
>> """UNIQUE_REFERENCE_NUMBER""" is null
>>
>
> By using the correct type specification at each variable insertion you can
> get this to work.
>
> Either do trial-and-error or actually reason through what is happening at
> each position and why it is either correct or wrong (build up the query in
> parts if that makes things easier).
>
> David J.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-12-16 21:37:29 Re: How to ensure column names are double quoted while using execute format when building a stored procedure?
Previous Message David G. Johnston 2021-12-16 21:25:39 Re: How to ensure column names are double quoted while using execute format when building a stored procedure?