Skip site navigation (1) Skip section navigation (2)

Problem with function-arguments

From: Hans Peter Ertz <hansi_mailinglisten(at)gmx(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Problem with function-arguments
Date: 2009-04-24 21:31:13
Message-ID: 49F22FA1.4020000@gmx.net (view raw or flat)
Thread:
Lists: pgsql-admin
Hello everyone!

First of all: I'm using Postgres 8.2.4 on a WinXP machine.

I'm trying to create a function that creates a new user-role to allow 
non-super-users to create users.

The function should look something like that (well, obviously it should 
not...but it's to give you an idea, what I'm talking about):

CREATE OR REPLACE FUNCTION sys.create_user(text, text)
   RETURNS void AS
$BODY$
	CREATE ROLE "$1" LOGIN PASSWORD '$2' INHERIT NOCREATEDB CREATEROLE;
$BODY$
   LANGUAGE 'sql' VOLATILE SECURITY DEFINER;

The statement "SELECT sys.create_user('myusername', 'mypassword'); " 
creates a user named $1 with password $2.......well....that's not whwat 
I want the function to do.....

Nearly any combination of double-quotes, single-quotes leads to a 
syntax-error when trying to create the function...

At the moment I'm running out of ideas...can anyone help?

Greetings and TIA,
Hans Peter Ertz

Responses

pgsql-admin by date

Next:From: Hans Peter ErtzDate: 2009-04-24 23:17:04
Subject: Re: Problem with function-arguments
Previous:From: Ries van TwiskDate: 2009-04-24 21:12:00
Subject: Re: Deleting "parent" record

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group