Numerical variables in pqsql statements

Поиск
Список
Период
Сортировка
От Michael Schmidt
Тема Numerical variables in pqsql statements
Дата
Msg-id BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl
обсуждение исходный текст
Ответы Re: Numerical variables in pqsql statements  ("Thomas F. O'Connell" <tfo@sitening.com>)
Список pgsql-sql
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.

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

Предыдущее
От: Chris Mungall
Дата:
Сообщение: Common patterns for 'store' functions
Следующее
От: "Matt A."
Дата:
Сообщение: question