I have a sql procedure that runs too long and I need to put it into a procedure so I can do a commit every 10000 rows or so. Does someone have a sample set of code to do this?
Here's the code:
INSERT INTO emp_0 (
SELECT
older.emp_id,
older.emp_time_stamp,
min(newer.emp_time_stamp),
newer.record_expired
FROM
emp_t older, emp_t newer
WHERE
older.emp_id = newer.emp_id and
older.emp_time_stamp < emp_time_stamp and
older.record_expired is null and
newer.record_updated = 'N'
GROUP BY
older.emp_id,
oleder.emp_time_stamp,
newer.record_expired);
Here's the code:
INSERT INTO emp_0 (
SELECT
older.emp_id,
older.emp_time_stamp,
min(newer.emp_time_stamp),
newer.record_expired
FROM
emp_t older, emp_t newer
WHERE
older.emp_id = newer.emp_id and
older.emp_time_stamp < emp_time_stamp and
older.record_expired is null and
newer.record_updated = 'N'
GROUP BY
older.emp_id,
oleder.emp_time_stamp,
newer.record_expired);