From 0fdca403744d98232bf332d2a72ae69d6a23312b Mon Sep 17 00:00:00 2001 From: linuxpoet Date: Tue, 24 Oct 2006 01:13:19 +0000 Subject: changed create_user to return users.id if successful git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@275 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/Pg-tables.sql | 4 ++-- sql/Pg-upgrade-2.6.18-2.6.19.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql index 5201e55e..c9771e4d 100755 --- a/sql/Pg-tables.sql +++ b/sql/Pg-tables.sql @@ -761,10 +761,10 @@ 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; + SELECT currval('user_id_seq'); $$ LANGUAGE 'SQL'; -COMMENT ON FUNCTION create_user(text) IS $$ Function to create user. Returns 1 if successful, else it is an error. $$; +COMMENT ON FUNCTION create_user(text) IS $$ Function to create user. Returns users.id if successful, else it is an error. $$; CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$ UPDATE users SET username = '$2' WHERE id = $1; 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 ce34ab29..924bd0ba 100644 --- a/sql/Pg-upgrade-2.6.18-2.6.19.sql +++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql @@ -195,10 +195,10 @@ COMMIT; CREATE FUNCTION create_user(text) RETURNS int4 AS $$ INSERT INTO users(username) VALUES ('$1'); - SELECT 1; + SELECT currval('user_id_seq'); $$ LANGUAGE 'SQL'; -COMMENT ON FUNCTION create_user(text) IS $$ Function to create user Returns 1 if successful, else it is an error. $$; +COMMENT ON FUNCTION create_user(text) IS $$ Function to create user Returns users.id if successful, else it is an error. $$; CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$ UPDATE users SET username = '$2' WHERE id = $1; -- cgit v1.2.3