[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6836] trunk/sql/consistency_checks.sql
- Subject: SF.net SVN: ledger-smb:[6836] trunk/sql/consistency_checks.sql
- From: ..hidden..
- Date: Mon, 10 Feb 2014 16:10:52 +0000
Revision: 6836
http://sourceforge.net/p/ledger-smb/code/6836
Author: tshvr
Date: 2014-02-10 16:10:52 +0000 (Mon, 10 Feb 2014)
Log Message:
-----------
consistency_checks begin
Added Paths:
-----------
trunk/sql/consistency_checks.sql
Added: trunk/sql/consistency_checks.sql
===================================================================
--- trunk/sql/consistency_checks.sql (rev 0)
+++ trunk/sql/consistency_checks.sql 2014-02-10 16:10:52 UTC (rev 6836)
@@ -0,0 +1,24 @@
+CREATE OR REPLACE FUNCTION consistency_checks
+(
+)
+RETURNS INT AS
+$$
+DECLARE rc int;
+DECLARE row_count int;
+BEGIN
+ perform * from acc_trans where trans_id in
+ ( select trans_id from acc_trans group by trans_id having sum(amount) <> 0 )
+ order by trans_id,transdate;
+
+ GET DIAGNOSTICS row_count = ROW_COUNT;
+ if row_count > 0 then
+ raise exception 'unbalanced transactions row_count=%',row_count;
+ end if;
+
+ rc=0;
+ return rc;
+END;
+$$ LANGUAGE PLPGSQL;
+--select consistency_checks from consistency_checks();
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits