pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Creating Users
6+ messages / 4 participants
[nested] [flat]

* Creating Users
@ 2001-08-14 14:45  Miguel Gonzalez <jffernandez@usuarios.retecal.es>
  0 siblings, 1 reply; 6+ messages in thread

From: Miguel Gonzalez @ 2001-08-14 14:45 UTC (permalink / raw)
  To: pgsql-admin

dear all,

 I am developing a client application with C++ Builder 3 to access a
Database designed with PostgreSQL 7.0.4 using a BDE alias through the ODBC
driver.

 I would like to have a form where I can add users to my users table of my
database and also create the corresponding entry to the postgres pg_user
table.

 What I have tried through the Database Explorer is the following
transaction (I use begin and commit, otherwise the parser complains):

 BEGIN;
 CREATE USER user1 WITH PASSWORD 'passwd_user1' IN GROUP users_invui;
 COMMIT;

 I check in the pg_user table but no entry is added. I execute without the
begin and the commit comands the same query in the backend (psql) and it
works perfectly. What am I doing wrong?

 Many thanks in advance and sorry for my English

 Miguel






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Creating Users
@ 2001-08-14 20:29  iafmgc@unileon.es
  0 siblings, 0 replies; 6+ messages in thread

From: iafmgc@unileon.es @ 2001-08-14 20:29 UTC (permalink / raw)
  To: pgsql-admin

dear all,

 I am developing a client application with C++ Builder 3 to access a
Database designed with PostgreSQL 7.0.4 using a BDE alias through the ODBC
driver.

 I would like to have a form where I can add users to my users table of my
database and also create the corresponding entry to the postgres pg_user
table.

 What I have tried through the Database Explorer is the following
transaction (I use begin and commit, otherwise the parser complains):

 BEGIN;
 CREATE USER user1 WITH PASSWORD 'passwd_user1' IN GROUP users_invui;
 COMMIT;

 I check in the pg_user table but no entry is added. I execute without the
begin and the commit comands the same query in the backend (psql) and it
works perfectly. What am I doing wrong?

 Many thanks in advance and sorry for my English

 Miguel







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Creating Users
@ 2001-08-20 17:25  Peter Eisentraut <peter_e@gmx.net>
  parent: Miguel Gonzalez <jffernandez@usuarios.retecal.es>
  0 siblings, 0 replies; 6+ messages in thread

From: Peter Eisentraut @ 2001-08-20 17:25 UTC (permalink / raw)
  To: Miguel Gonzalez <jffernandez@usuarios.retecal.es>; +Cc: pgsql-admin

Miguel Gonzalez writes:

>  I am developing a client application with C++ Builder 3 to access a
> Database designed with PostgreSQL 7.0.4 using a BDE alias through the ODBC
> driver.

Time to upgrade.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* RE: Creating Users
@ 2001-08-21 16:12  Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 6+ messages in thread

From: Peter Eisentraut @ 2001-08-21 16:12 UTC (permalink / raw)
  To: Miguel Gonzalez <jffernandez@usuarios.retecal.es>; +Cc: pgsql-admin

Miguel Gonzalez writes:

> Could you be a bit more specific? Time to upgrade to what?

PostgreSQL

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re:Creating Users
@ 2001-08-21 17:28  iafmgc@unileon.es
  0 siblings, 0 replies; 6+ messages in thread

From: iafmgc@unileon.es @ 2001-08-21 17:28 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Peter Eisentraut <peter_e@gmx.net>

Could you be a bit more specific? Time to upgrade to what?

Many thanks Miguel

----- Original Message -----
From: Peter Eisentraut <peter_e@gmx.net>
To: Miguel Gonzalez <jffernandez@usuarios.retecal.es>
Cc: PostgreSqlAdmin <pgsql-admin@postgresql.org>
Sent: Monday, August 20, 2001 7:25 PM
Subject: Re: [ADMIN] Creating Users


> Miguel Gonzalez writes:
>
> >  I am developing a client application with C++ Builder 3 to access a
> > Database designed with PostgreSQL 7.0.4 using a BDE alias through the
ODBC
> > driver.
>
> Time to upgrade.
>
> --
> Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* CREATING USERS
@ 2002-04-24 00:42  Aaron Spiteri <aaron@m1group.com.au>
  0 siblings, 0 replies; 6+ messages in thread

From: Aaron Spiteri @ 2002-04-24 00:42 UTC (permalink / raw)
  To: pgsql-admin

I am having some trouble with a PL/SQL script I have been trying to 
write.  The idea is that a table is created called user_table, This 
stores extra information about each user on the system.  There is a link 
in the user_table called usename which links up to pg_shadow.username.  I 
want to be able to create new users, alter existing users or drop users 
depending on insertion, deletion or altercation of the user_table.  The 
code I wrote looks like this:

CREATE FUNCTION insert_svoc_user() RETURNS OPAQUE AS '
DECLARE
	r record;
	b bool DEFAULT ''f'';
BEGIN
	FOR r IN SELECT pg_shadow.usename FROM pg_shadow WHERE pg_shadow.usename 
= NEW.usename LOOP
		IF r.usename = NEW.usename THEN
			b := ''t'';
		END IF;
	END LOOP;
	IF b = ''t'' THEN
		ALTER USER NEW.usename IN GROUP NEW.groname;
	ELSE
	 	CREATE USER NEW.usename IN GROUP NEW.groname; 
	END IF;
	RETURN NEW;
END;
'
LANGUAGE 'plpgsql';

/*
 * update_user
 * -----------
 * This functions changes a users group on update of the user_table table
 */
CREATE FUNCTION update_svoc_user() RETURNS OPAQUE AS '
DECLARE
	r record;
	b bool DEFAULT ''f'';
BEGIN
	FOR r IN SELECT usename FROM pg_shadow WHERE pg_shadow.usename = 
NEW.usename LOOP
		IF r.username = NEW.usename THEN
			b := ''t'';
		END IF;
	END LOOP;
	IF b = ''f'' THEN
	 	CREATE USER NEW.usename IN GROUP NEW.groname;		
	END IF
	IF NOT NEW.groname = OLD.groname AND b = ''t'' THEN
		ALTER USER NEW.usename IN GROUP NEW.groname;
	END IF;
	RETURN NEW;
	
END;
'
LANGUAGE 'plpgsql';


/* 
 * delete_user
 * This function removes a user from the database if they are deleted 
from
 * the user_det table.
 *
 */
CREATE FUNCTION delete_svoc_user() RETURNS OPAQUE AS '
DECLARE
	r record;
BEGIN
	FOR r IN SELECT usename FROM pg_shadow WHERE pg_shadow.usename = 
OLD.usename LOOP
		IF r.usename = OLD.usename THEN
			DROP USER OLD.usename;
		END IF;
	END LOOP;
	RETURN OLD;
END;
'
LANGUAGE 'plpgsql';


I am continuusly getting an error Can not copyObject() error writing to 
$1.  I have looked up the pg archives and think the problem may be a 
limitation with in the PL SQL code, thus I was thinking of trying to 
rewrite it in PL/ TCL can anyone give some pointers on how to do this.

Aaron





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-04-24 00:42 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-08-14 14:45 Creating Users Miguel Gonzalez <jffernandez@usuarios.retecal.es>
2001-08-20 17:25 ` Peter Eisentraut <peter_e@gmx.net>
2001-08-14 20:29 Creating Users iafmgc@unileon.es
2001-08-21 16:12 RE: Creating Users Peter Eisentraut <peter_e@gmx.net>
2001-08-21 17:28 Re:Creating Users iafmgc@unileon.es
2002-04-24 00:42 CREATING USERS Aaron Spiteri <aaron@m1group.com.au>

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