Re: plperl syntax question

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: plperl syntax question
Date: 2020-03-12 22:45:58
Message-ID: 1F75920B-15CE-445F-8F2A-B8740DC845D8@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Mar 12, 2020, at 4:34 PM, stan <stanb(at)panix(dot)com> wrote:
>
> I am trying to run a query in plperl that uses a Perl variable from the
> same function.
>
> Here is the code snippet:
>
> my $stmt = qq("SELECT employee_key from employee where id = '$user' ;");
> elog( NOTICE, "stmt = $stmt" );
> my $rv3 = spi_exec_query('$stmt');
>
> Here is the runtime output:
>
> NOTICE: stmt = "SELECT employee_key from employee where id = 'stan' ;"
> ERROR: syntax error at or near "$" at line 22.
>
> As you can see, the statement seems correctly formatted, right?
>
> What am I doing wrong here?
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
?try
my $rv3 = spi_exec_query($stmt);
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kyotaro Horiguchi 2020-03-13 00:49:26 Re: polygon && polygon and precision
Previous Message stan 2020-03-12 22:34:02 plperl syntax question