From: Rob Sargent <robjsargent@gmail.com>
To: stan <stanb@panix.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: plperl syntax question
Date: Thu, 12 Mar 2020 16:45:58 -0600
Message-ID: <1F75920B-15CE-445F-8F2A-B8740DC845D8@gmail.com> (raw)
In-Reply-To: <20200312223402.GA613@panix.com>
References: <20200312223402.GA613@panix.com>
> On Mar 12, 2020, at 4:34 PM, stan <stanb@panix.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);
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, stanb@panix.com
Subject: Re: plperl syntax question
In-Reply-To: <1F75920B-15CE-445F-8F2A-B8740DC845D8@gmail.com>
References: <20200312223402.GA613@panix.com> <1F75920B-15CE-445F-8F2A-B8740DC845D8@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox