[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3531] trunk/sql/modules/Settings.sql
- Subject: SF.net SVN: ledger-smb:[3531] trunk/sql/modules/Settings.sql
- From: ..hidden..
- Date: Sat, 16 Jul 2011 00:37:10 +0000
Revision: 3531
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3531&view=rev
Author: einhverfr
Date: 2011-07-16 00:37:09 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Docstrings to Settings.sql
Modified Paths:
--------------
trunk/sql/modules/Settings.sql
Modified: trunk/sql/modules/Settings.sql
===================================================================
--- trunk/sql/modules/Settings.sql 2011-07-16 00:19:29 UTC (rev 3530)
+++ trunk/sql/modules/Settings.sql 2011-07-16 00:37:09 UTC (rev 3531)
@@ -1,19 +1,29 @@
-- VERSION 1.3.0
CREATE OR REPLACE FUNCTION setting_set (in_key varchar, in_value varchar)
-RETURNS VOID AS
+RETURNS BOOL AS
$$
BEGIN
UPDATE defaults SET value = in_value WHERE setting_key = in_key;
- RETURN;
+ IF NOT FOUND THEN
+ INSERT INTO defaults (setting_key, value)
+ VALUES (in_setting_key, in_value);
+ END IF;
+ RETURNS TRUE;
END;
$$ language plpgsql;
+COMMENT ON FUNCTION setting_set (in_key varchar, in_value varchar) IS
+$$ sets a value in the defaults thable and returns true if successful.$$;
+
CREATE OR REPLACE FUNCTION setting_get (in_key varchar) RETURNS defaults AS
$$
SELECT * FROM defaults WHERE setting_key = $1;
$$ LANGUAGE sql;
+COMMENT ON FUNCTION setting_get (in_key varchar) IS
+$$ Returns the value of the setting in the defaults table.$$;
+
CREATE OR REPLACE FUNCTION setting_get_default_accounts ()
RETURNS SETOF defaults AS
$$
@@ -23,12 +33,16 @@
FOR account IN
SELECT * FROM defaults
WHERE setting_key like '%accno_id'
+ ORDER BY setting_key
LOOP
RETURN NEXT account;
END LOOP;
END;
$$ LANGUAGE plpgsql;
+COMMENT ON FUNCTION setting_get_default_accounts () IS
+$$ Returns a set of settings for default accounts.$$;
+
CREATE OR REPLACE FUNCTION setting_increment (in_key varchar) returns varchar
AS
$$
@@ -64,6 +78,12 @@
END;
$$ LANGUAGE PLPGSQL;
+COMMENT ON FUNCTION setting_increment (in_key varchar) IS
+$$This function takes a value for a sequence in the defaults table and increments
+it. Leading zeroes and spaces are preserved as placeholders. Currently <?lsmb
+parsing is not supported in this routine though it may be added at a later date.
+$$;
+
CREATE OR REPLACE FUNCTION setting__get_currencies() RETURNS text[]
AS
$$
@@ -71,5 +91,8 @@
$$ LANGUAGE SQL;
-- Table schema defaults
+COMMENT ON FUNCTION setting__get_currencies() is
+$$ Returns an array of currencies from the defaults table.$$;
+
ALTER TABLE entity ALTER control_code SET default setting_increment('entity_control');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.