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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: How to ensure column names are double quoted while using execute format when building a stored procedure?
Дата
Msg-id CAKFQuwbGYaCzAhyqu2FMB6xVYMNBjWEGRiGz873AnzMysF9a5w@mail.gmail.com
обсуждение исходный текст
Ответ на How to ensure column names are double quoted while using execute format when building a stored procedure?  (Shaozhong SHI <shishaozhong@gmail.com>)
Ответы Re: How to ensure column names are double quoted while using execute format when building a stored procedure?  (Shaozhong SHI <shishaozhong@gmail.com>)
Список pgsql-general
On Thu, Dec 16, 2021 at 1:21 PM Shaozhong SHI <shishaozhong@gmail.com> wrote:
The following command runs but does not produce results as expected.
 
Execute Format('insert into stats select %L as id, %2$L as checks, count(%3$s) from %4$s where %5$s is null', i, 'count of nulls in '||col, col, t_name, col);

All columns have got capital letters in.  How to ensure that the columns are double-quote when they are fed in as variables.


Quoting the relevant doc section:


type (required)
The type of format conversion to use to produce the format specifier's output. The following types are supported:

s formats the argument value as a simple string. A null value is treated as an empty string.

I treats the argument value as an SQL identifier, double-quoting it if necessary. It is an error for the value to be null (equivalent to quote_ident).

L quotes the argument value as an SQL literal. A null value is displayed as the string NULL, without quotes (equivalent to quote_nullable).

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Shaozhong SHI
Дата:
Сообщение: How to ensure column names are double quoted while using execute format when building a stored procedure?
Следующее
От: Bryn Llewellyn
Дата:
Сообщение: Re: Packages, inner subprograms, and parameterizable anonymous blocks for PL/pgSQL