pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Schmidt <MichaelMSchmidt@msn.com>
To: pgsql-sql@postgresql.org
Subject: Numerical variables in pqsql statements
Date: Sun, 21 Aug 2005 18:43:33 -0600
Message-ID: <BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl> (raw)

Folks,
I'm sure this is dumb, but I'm a little confused about use of numerical variables in pqsql.  It was my impression one had to use EXECUTE on a concatenated string including quote_literal() for the variable containing the value.  This can be quite a bit of trouble.  I just wrote a function that included the statement :

CREATE TEMPORARY TABLE author_names AS 
      SELECT ra.ref_auth_key, a.last_name, a.first_name 
      FROM ref_auth ra INNER JOIN authors a
      ON (ra.author_num = a.author_key) 
      WHERE ra.ref_num = refer_num;

where refer_num is integer.  This worked (surprisingly, to me).  So, what is the rule regarding variables?  Would this query work if I concatenated a string together, including quote_literal(refer_num) and then EXECUTEd it?

Thanks and sorry to be so stupid.

view thread (3+ messages)  latest in thread

Message-ID: <BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl>
Permalink:  ../BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl/
Also on:    postgresql.org/message-id/BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: MichaelMSchmidt@msn.com
  Subject: Re: Numerical variables in pqsql statements
  In-Reply-To: <BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl>

* 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