[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1129] branches/1.2/utils/fixme/fixme.pgsql



Revision: 1129
          http://svn.sourceforge.net/ledger-smb/?rev=1129&view=rev
Author:   einhverfr
Date:     2007-05-06 10:32:01 -0700 (Sun, 06 May 2007)

Log Message:
-----------
Fixing fixme.pgsql

Modified Paths:
--------------
    branches/1.2/utils/fixme/fixme.pgsql

Modified: branches/1.2/utils/fixme/fixme.pgsql
===================================================================
--- branches/1.2/utils/fixme/fixme.pgsql	2007-05-06 17:05:27 UTC (rev 1128)
+++ branches/1.2/utils/fixme/fixme.pgsql	2007-05-06 17:32:01 UTC (rev 1129)
@@ -25,11 +25,11 @@
 
 CREATE TEMPORARY VIEW id_view1 AS
 SELECT id, count(*) AS num_rows FROM id_agregator 
-GROUP BY id HAVING num_rows > 1;
+GROUP BY id HAVING count(*) > 1;
 
-select setval('id', select max(id) + 1 from id_agregator);
+select setval('id', (select max(id) + 1 from id_agregator));
 
-create function fix_dupes() RETURNS OPAQUE AS
+create function fix_dupes() RETURNS opaque AS
 ' 
 DECLARE
 dupe_id id_agregator%ROWTYPE;
@@ -38,20 +38,23 @@
 	WHERE id IN (SELECT id FROM id_view1)
 LOOP
 	EXECUTE ''UPDATE '' || dupe_id.table_name ||
-			SET id = nextval(''''id'''') WHERE
+			'' SET id = nextval(''''id'''') WHERE
 		id = '' ||dupe_id.id;
 	UPDATE acc_trans SET trans_id = currval(''id'') WHERE
-		id = '' ||dupe_id.id;
+		id = ||dupe_id.id;
 	INSERT INTO acc_trans (trans_id, amount, chart_id) VALUES (
-		currval(''id''), '1', (
+		currval(''id''), ''1'', (
 			SELECT id FROM chart WHERE accno = ''1000000000''
 		)
 	);
 	INSERT INTO acc_trans (trans_id, amount, chart_id) VALUES (
-		currval(''id''), '-1', (
+		currval(''id''), ''-1'', (
 			SELECT id FROM chart WHERE accno = ''1000000000''
 		)
 	);
+
+END LOOP;
+RETURN NULL;
 END;
 ' LANGUAGE PLPGSQL;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.