quoting internal variable names

Поиск
Список
Период
Сортировка
От Ron Peterson
Тема quoting internal variable names
Дата
Msg-id 20050219223025.GA10322@mtholyoke.edu
обсуждение исходный текст
Ответы Re: quoting internal variable names  (Ron Peterson <rpeterso@mtholyoke.edu>)
Re: quoting internal variable names  (Peter Eisentraut <peter_e@gmx.net>)
Re: quoting internal variable names  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

I'm trying to use PostgreSQL's internal variables to simplify some shell
scripting database setup stuff.  Single quotes appear to behave
differently in diffent contexts.


CREATE USER
  :v_dbadmin
WITH PASSWORD
  ':v_dbpass';
CREATE USER

....CREATE USER worked o.k.


CREATE DATABASE
  :v_dbname
WITH OWNER
  :v_dbadmin
ENCODING
  ':v_encoding';
ERROR:  :v_encoding is not a valid encoding name

....here the quotation marks appear to throwing things off


:v_encoding is set to SQL_ASCII.  If I remove the quotation marks, then
I (appropriately enough) get the error:

CREATE DATABASE
  :v_dbname
WITH OWNER
  :v_dbadmin
ENCODING
  :v_encoding;
ERROR:  syntax error at or near "SQL_ASCII" at character 59
LINE 6:   SQL_ASCII;


So it seems like the single quotes are causing :v_encoding to be read as
a string literal for ENCODING, but they don't do that for WITH PASSWORD.

?

--
Ron Peterson
Network & Systems Manager
Mount Holyoke College
http://www.mtholyoke.edu/~rpeterso

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

Предыдущее
От: "S.D."
Дата:
Сообщение: Re: PGSQL 8.0.1 Win 2K Installation Problem
Следующее
От: Ron Peterson
Дата:
Сообщение: Re: quoting internal variable names