Subject | Re: Progress of a Stored Procedure Feedback |
---|---|
Author | robertgilland |
Post date | 2006-06-27T06:56:49Z |
Thank you helen,
this is the final outline from the stored procedure.
Unless there is a quicker way to get the select to go
to the records we need.
Regards,
Robert.
CREATE PROCEDURE PROC_EXT_FIELD3SALES
( ROWS_PROCESSED_SO_FAR INTEGER, ROWS_PERCYCLE INTEGER )
RETURNS
( BATCH_ROWS_PROCESSED INTEGER )
AS
DECLARE VARIABLE THEFIELD1 VARCHAR(10);
DECLARE VARIABLE THEFIELD2 TIMESTAMP;
DECLARE VARIABLE THEFIELD3 VARCHAR(14);
DECLARE VARIABLE THEFIELD4 FLOAT;
DECLARE VARIABLE THEFIELD5 FLOAT;
DECLARE VARIABLE THEFIELD6 FLOAT;
DECLARE VARIABLE THEFIELD7 FLOAT;
DECLARE VARIABLE THEFIELD8 FLOAT;
DECLARE VARIABLE THECOUNT INTEGER;
BEGIN
THECOUNT = 0;
FOR SELECT CAST( RTRIM( FIELD1 ) AS VARCHAR(10) ) AS FIELD1
,CAST( FIELD2 AS TIMESTAMP ) AS FIELD2
,CAST( RTRIM( FIELD3 ) AS VARCHAR(14) ) AS FIELD3
,CAST( FIELD4 AS FLOAT ) AS FIELD4
,CAST( FIELD5 AS FLOAT ) AS FIELD5
,CAST( FIELD6 AS FLOAT ) AS FIELD6
,CAST( FIELD7 AS FLOAT ) AS FIELD7
,CAST( FIELD8 AS FLOAT ) AS FIELD8
FROM EXT_FIELD3SALES
INTO :THEFIELD1
,:THEFIELD2
,:THEFIELD3
,:THEFIELD4
,:THEFIELD5
,:THEFIELD6
,:THEFIELD7
,:THEFIELD8
DO
BEGIN
IF( THECOUNT >= ROWS_PROCESSED_SO_FAR )THEN
BEGIN
INSERT INTO FIELD3SALES
(FIELD1
,FIELD2
,FIELD3
,FIELD4
,FIELD5
,FIELD6
,FIELD7
,FIELD8
)
VALUES
(:THEFIELD1
,:THEFIELD2
,:THEFIELD3
,:THEFIELD4
,:THEFIELD5
,:THEFIELD6
,:THEFIELD7
,:THEFIELD8
);
WHEN SQLCODE -803 DO
BEGIN
UPDATE FIELD3SALES
SET FIELD4 = :THEFIELD4
,FIELD5 = :THEFIELD5
,FIELD6 = :THEFIELD6
,FIELD7 = :THEFIELD7
,FIELD8 = :THEFIELD8
WHERE (FIELD1 = :THEFIELD1 )
AND (FIELD2 = :THEFIELD2 )
AND (FIELD3 = :THEFIELD3 )
;
END
END
THECOUNT = THECOUNT + 1;
IF(( THECOUNT - ROWS_PROCESSED_SO_FAR ) >= ROWS_PERCYCLE )THEN
LEAVE;
END
BATCH_ROWS_PROCESSED = THECOUNT;
SUSPEND;
END;
this is the final outline from the stored procedure.
Unless there is a quicker way to get the select to go
to the records we need.
Regards,
Robert.
CREATE PROCEDURE PROC_EXT_FIELD3SALES
( ROWS_PROCESSED_SO_FAR INTEGER, ROWS_PERCYCLE INTEGER )
RETURNS
( BATCH_ROWS_PROCESSED INTEGER )
AS
DECLARE VARIABLE THEFIELD1 VARCHAR(10);
DECLARE VARIABLE THEFIELD2 TIMESTAMP;
DECLARE VARIABLE THEFIELD3 VARCHAR(14);
DECLARE VARIABLE THEFIELD4 FLOAT;
DECLARE VARIABLE THEFIELD5 FLOAT;
DECLARE VARIABLE THEFIELD6 FLOAT;
DECLARE VARIABLE THEFIELD7 FLOAT;
DECLARE VARIABLE THEFIELD8 FLOAT;
DECLARE VARIABLE THECOUNT INTEGER;
BEGIN
THECOUNT = 0;
FOR SELECT CAST( RTRIM( FIELD1 ) AS VARCHAR(10) ) AS FIELD1
,CAST( FIELD2 AS TIMESTAMP ) AS FIELD2
,CAST( RTRIM( FIELD3 ) AS VARCHAR(14) ) AS FIELD3
,CAST( FIELD4 AS FLOAT ) AS FIELD4
,CAST( FIELD5 AS FLOAT ) AS FIELD5
,CAST( FIELD6 AS FLOAT ) AS FIELD6
,CAST( FIELD7 AS FLOAT ) AS FIELD7
,CAST( FIELD8 AS FLOAT ) AS FIELD8
FROM EXT_FIELD3SALES
INTO :THEFIELD1
,:THEFIELD2
,:THEFIELD3
,:THEFIELD4
,:THEFIELD5
,:THEFIELD6
,:THEFIELD7
,:THEFIELD8
DO
BEGIN
IF( THECOUNT >= ROWS_PROCESSED_SO_FAR )THEN
BEGIN
INSERT INTO FIELD3SALES
(FIELD1
,FIELD2
,FIELD3
,FIELD4
,FIELD5
,FIELD6
,FIELD7
,FIELD8
)
VALUES
(:THEFIELD1
,:THEFIELD2
,:THEFIELD3
,:THEFIELD4
,:THEFIELD5
,:THEFIELD6
,:THEFIELD7
,:THEFIELD8
);
WHEN SQLCODE -803 DO
BEGIN
UPDATE FIELD3SALES
SET FIELD4 = :THEFIELD4
,FIELD5 = :THEFIELD5
,FIELD6 = :THEFIELD6
,FIELD7 = :THEFIELD7
,FIELD8 = :THEFIELD8
WHERE (FIELD1 = :THEFIELD1 )
AND (FIELD2 = :THEFIELD2 )
AND (FIELD3 = :THEFIELD3 )
;
END
END
THECOUNT = THECOUNT + 1;
IF(( THECOUNT - ROWS_PROCESSED_SO_FAR ) >= ROWS_PERCYCLE )THEN
LEAVE;
END
BATCH_ROWS_PROCESSED = THECOUNT;
SUSPEND;
END;