Conditional commit inside functions

From: Gerhard Wiesinger <lists(at)wiesinger(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Conditional commit inside functions
Date: 2008-12-25 11:17:21
Message-ID: alpine.LFD.1.10.0812251214420.31597@bbs.intern
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I want to translate the following Oracle PL/SQL script into plpgsql.
Especially I'm having problems with the transaction thing. i tried START
TRANSACTION and COMMIT without success.

Any ideas?

Thanx.

Ciao,
Gerhard

CREATE OR REPLACE PROCEDURE insert_1Mio
IS
maxcommit NUMBER;
BEGIN
maxcommit := 10000;

FOR i IN 1..1000000 LOOP
INSERT INTO employee (id, department, firstname, lastname) VALUES (i, i, 'John' || to_char(i), 'Smith' || to_char(i));
IF MOD(i, maxcommit) = 0 THEN
COMMIT;
END IF;
END LOOP;

COMMIT;
END;

--
http://www.wiesinger.com/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2008-12-25 12:58:13 Re: Conditional commit inside functions
Previous Message Pavel Stehule 2008-12-25 10:50:09 Re: Information about Pages, row versions of tables, indices