summaryrefslogtreecommitdiff
path: root/utils/fixme
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-06 17:56:02 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-06 17:56:02 +0000
commit7a8d05934ffc6400c57f8331f55e73f9ceed502c (patch)
tree63710ff994f5128530c9848d92d00b84505b71c4 /utils/fixme
parentfc1e4a3c139cbd7c200c26286b3130a284d37e0b (diff)
Fixing bug 1708011
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1131 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'utils/fixme')
-rw-r--r--utils/fixme/fixme.pgsql17
1 files changed, 10 insertions, 7 deletions
diff --git a/utils/fixme/fixme.pgsql b/utils/fixme/fixme.pgsql
index 7ee23b4d..28ba8183 100644
--- a/utils/fixme/fixme.pgsql
+++ b/utils/fixme/fixme.pgsql
@@ -25,11 +25,11 @@ insert into id_agregator (id, table_name) SELECT id, 'warehouse' from warehouse;
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 @@ FOR dupe_id IN SELECT id FROM id_agregator
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;