diff options
Diffstat (limited to 'sql/Pg-tables.sql')
-rwxr-xr-x | sql/Pg-tables.sql | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql index d512ccbb..5201e55e 100755 --- a/sql/Pg-tables.sql +++ b/sql/Pg-tables.sql @@ -757,3 +757,20 @@ COMMENT ON COLUMN users_conf.password IS 'This means we have to get rid of the c -- The two below statements must be run from a single session INSERT INTO users(username) VALUES ('admin'); INSERT INTO users_conf(id,password) VALUES (currval('users_id_seq'),NULL); + + +CREATE FUNCTION create_user(text) RETURNS int4 AS $$ + INSERT INTO users(username) VALUES ('$1'); + SELECT 1; + $$ LANGUAGE 'SQL'; + +COMMENT ON FUNCTION create_user(text) IS $$ Function to create user. Returns 1 if successful, else it is an error. $$; + +CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$ + UPDATE users SET username = '$2' WHERE id = $1; + SELECT 1; + $$ LANGUAGE 'SQL'; + +COMMENT ON FUNCTION update_user(int4,text) IS $$ Takes int4 which is users.id and text which is username. Will update username based on id. Username is unique $$; + + |