Re: plperl syntax question

Поиск
Список
Период
Сортировка
От stan
Тема Re: plperl syntax question
Дата
Msg-id 20200313014438.GB6722@panix.com
обсуждение исходный текст
Ответ на Re: plperl syntax question  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: plperl syntax question  (Rob Sargent <robjsargent@gmail.com>)
Список pgsql-general
On Thu, Mar 12, 2020 at 06:37:02PM -0700, David G. Johnston wrote:
> On Thursday, March 12, 2020, stan <stanb@panix.com> wrote:
> >
> > my $rv3 = spi_exec_query('$stmt');
> > What am I doing wrong here?
> >
> 
> Putting a variable name into a single-quoted string and expecting it to
> resolve to the contents of said variable instead of being treated as a
> literal.
> David J.

Please look at this.

Here is the code:

my $stmt = qq('SELECT employee_key from employee where id = $user ;');
elog( NOTICE, "stmt = $stmt" );
my $rv3 = spi_exec_query($stmt);

As you cna see, I use qq to ahndle the qouting: runtime output looks like
this:

OTICE:  stmt = 'SELECT employee_key from employee where id = stan ;'
ERROR:  syntax error at or near "$" at line 22.

Looks like a very clean string with the variable substituted.

Anyone have a working example of a call to spi_exec_query() using a variable?

also tried:

my $rv3 = spi_exec_query('$stmt');

Different trun tiem error message.


-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
                        -- Benjamin Franklin



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

Предыдущее
От: stan
Дата:
Сообщение: Re: plperl syntax question
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: plperl syntax question