[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [274] trunk/sql
- Subject: SF.net SVN: ledger-smb: [274] trunk/sql
- From: ..hidden..
- Date: Mon, 23 Oct 2006 18:01:58 -0700
Revision: 274
http://svn.sourceforge.net/ledger-smb/?rev=274&view=rev
Author: linuxpoet
Date: 2006-10-23 18:01:52 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
added functions create_user and update_user.. see docs
Modified Paths:
--------------
trunk/sql/Pg-tables.sql
trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql
Modified: trunk/sql/Pg-tables.sql
===================================================================
--- trunk/sql/Pg-tables.sql 2006-10-24 00:55:44 UTC (rev 273)
+++ trunk/sql/Pg-tables.sql 2006-10-24 01:01:52 UTC (rev 274)
@@ -757,3 +757,20 @@
-- 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 $$;
+
+
Modified: trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql
===================================================================
--- trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql 2006-10-24 00:55:44 UTC (rev 273)
+++ trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql 2006-10-24 01:01:52 UTC (rev 274)
@@ -189,4 +189,20 @@
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 $$;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.