Обсуждение: Pgscript : error creating a user with a variable as the password
Hi all,
This is a problem about creating a user with a password thanks to a pgscript (pgadmin 1.14.1). I have searched a while around the internent, but I have found no solution so far.
The following script does not work ("error near « password»". Pgadmin is in French, so i do not know how the warning exactly looks like in English) :
declare @USER, @PASS;
set @USER='user';
set @PASS='password';
CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD @PASS;
Whereas this one does :
declare @USER;
set @USER='user';
CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD 'password';
What am I doing wrong with the @PASS variable ?
Thank you for your support, and congrats for what you do.
VP
This is a problem about creating a user with a password thanks to a pgscript (pgadmin 1.14.1). I have searched a while around the internent, but I have found no solution so far.
The following script does not work ("error near « password»". Pgadmin is in French, so i do not know how the warning exactly looks like in English) :
declare @USER, @PASS;
set @USER='user';
set @PASS='password';
CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD @PASS;
Whereas this one does :
declare @USER;
set @USER='user';
CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD 'password';
What am I doing wrong with the @PASS variable ?
Thank you for your support, and congrats for what you do.
VP
Le 16/03/2012 14:23, plop plop a écrit : > Hi all, > > This is a problem about creating a user with a password thanks to a > pgscript (pgadmin 1.14.1). I have searched a while around the internent, > but I have found no solution so far. > > The following script does not work ("error near « password»". Pgadmin is > in French, so i do not know how the warning exactly looks like in English) : > > declare @USER, @PASS; > set @USER='user'; > set @PASS='password'; > > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE > PASSWORD @PASS; > > > Whereas this one does : > > declare @USER; > set @USER='user'; > > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE > PASSWORD 'password'; > > > What am I doing wrong with the @PASS variable ? > You need to add quotes around it, this way: CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD '@PASS'; -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com
Hi,
I am wondering why I haven't tried that...
Thanks a lot, that works well.
VP
I am wondering why I haven't tried that...
Thanks a lot, that works well.
VP
> Date: Sun, 18 Mar 2012 09:40:43 +0100
> From: guillaume@lelarge.info
> To: mr_weetos@hotmail.com
> CC: pgadmin-support@postgresql.org
> Subject: Re: [pgadmin-support] Pgscript : error creating a user with a variable as the password
>
> Le 16/03/2012 14:23, plop plop a écrit :
> > Hi all,
> >
> > This is a problem about creating a user with a password thanks to a
> > pgscript (pgadmin 1.14.1). I have searched a while around the internent,
> > but I have found no solution so far.
> >
> > The following script does not work ("error near « password»". Pgadmin is
> > in French, so i do not know how the warning exactly looks like in English) :
> >
> > declare @USER, @PASS;
> > set @USER='user';
> > set @PASS='password';
> >
> > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> > PASSWORD @PASS;
> >
> >
> > Whereas this one does :
> >
> > declare @USER;
> > set @USER='user';
> >
> > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> > PASSWORD 'password';
> >
> >
> > What am I doing wrong with the @PASS variable ?
> >
>
> You need to add quotes around it, this way:
>
> CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> PASSWORD '@PASS';
>
>
> --
> Guillaume
> http://blog.guillaume.lelarge.info
> http://www.dalibo.com
>
> --
> Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-support
> From: guillaume@lelarge.info
> To: mr_weetos@hotmail.com
> CC: pgadmin-support@postgresql.org
> Subject: Re: [pgadmin-support] Pgscript : error creating a user with a variable as the password
>
> Le 16/03/2012 14:23, plop plop a écrit :
> > Hi all,
> >
> > This is a problem about creating a user with a password thanks to a
> > pgscript (pgadmin 1.14.1). I have searched a while around the internent,
> > but I have found no solution so far.
> >
> > The following script does not work ("error near « password»". Pgadmin is
> > in French, so i do not know how the warning exactly looks like in English) :
> >
> > declare @USER, @PASS;
> > set @USER='user';
> > set @PASS='password';
> >
> > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> > PASSWORD @PASS;
> >
> >
> > Whereas this one does :
> >
> > declare @USER;
> > set @USER='user';
> >
> > CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> > PASSWORD 'password';
> >
> >
> > What am I doing wrong with the @PASS variable ?
> >
>
> You need to add quotes around it, this way:
>
> CREATE ROLE @USER LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE
> PASSWORD '@PASS';
>
>
> --
> Guillaume
> http://blog.guillaume.lelarge.info
> http://www.dalibo.com
>
> --
> Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-support