Create User

Поиск
Список
Период
Сортировка
От DB Subscriptions
Тема Create User
Дата
Msg-id 43D09C7B.90101@shepherdhill.biz
обсуждение исходный текст
Ответы Re: Create User  (Pandurangan R S <pandurangan.r.s@gmail.com>)
Re: Create User  (Neil Conway <neilc@samurai.com>)
Список pgsql-general
Hi,

I have this table:

CREATE TABLE users
(
  userid varchar(100) NOT NULL,
  nama varchar(50) NOT NULL,
  pword varchar(255) NOT NULL,
  groupe varchar(7) NOT NULL,
  rolle int2 NOT NULL DEFAULT 2,
  statux varchar(9) NOT NULL DEFAULT 'Active'::character varying,
  CONSTRAINT users_pkey PRIMARY KEY (userid)
)
WITHOUT OIDS;

I created a trigger to create a user based on the new insert into the
table as follows:

CREATE OR REPLACE FUNCTION users_insert()
  RETURNS "trigger" AS
$BODY$
BEGIN
    CREATE USER NEW.userid WITH PASSWORD NEW.pword IN GROUP NEW.groupe;

    RETURN new;
END;

$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Surprisingly, I get this error message:

ERROR:  syntax error at or near "$1" at character 14
QUERY:  CREATE USER  $1  WITH PASSWORD  $2  IN GROUP  $3
CONTEXT:  SQL statement in PL/PgSQL function "users_insert" near line 10

I would appreciate your guidance.

Cheers.

Chris.



___________________________________________________________
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com

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

Предыдущее
От: "Peter Zeltins"
Дата:
Сообщение: Re: Using rowtype parameter
Следующее
От: Steve Taylor
Дата:
Сообщение: psql: FATAL: password authentication failed for user "xxxx"