diff options
author | linuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-24 01:01:52 +0000 |
---|---|---|
committer | linuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-24 01:01:52 +0000 |
commit | 29a8cd2abffc6a422142cef31961e316441d42f7 (patch) | |
tree | dead2cb9ecc93b94ae8b24cd8f30e01401870265 /sql | |
parent | 944f6ac23540eab0535fa3769442f3318dd4eb79 (diff) |
added functions create_user and update_user.. see docs
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@274 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rwxr-xr-x | sql/Pg-tables.sql | 17 | ||||
-rw-r--r-- | sql/Pg-upgrade-2.6.18-2.6.19.sql | 18 |
2 files changed, 34 insertions, 1 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 $$; + + diff --git a/sql/Pg-upgrade-2.6.18-2.6.19.sql b/sql/Pg-upgrade-2.6.18-2.6.19.sql index f06f661e..ce34ab29 100644 --- a/sql/Pg-upgrade-2.6.18-2.6.19.sql +++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql @@ -189,4 +189,20 @@ COMMIT; BEGIN; INSERT INTO users(username) VALUES ('admin'); INSERT INTO users_conf(id,password) VALUES (currval('users_id_seq'),NULL); -COMMIT;
\ No newline at end of file +COMMIT; + +-- Functions + +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 $$; |