Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Procedure sintex

$
0
0
Hello I am new to db2. Could some one help me. I need to write a procedure where it will check a columnt in a table which has unique numbers and if a number is missing then it will insert a record with the missing number.

Thank you.

CREATE PROCEDURE SUBJECT_CREATION
LANGUAGE SQL
BEGIN
DECLARE V_COUNTER SMALLINT;
DECLARE V_FID SMALLINT;
DECLARE c1 CURSOR FOR SELECT FID FROM INDIC.SUBJECT WHERE FID < 301;
OPEN c1;
LOO: LOOP
FETCH c1 INTO v_fid ;
IF V_COUNTER != v_fid THEN
INSERT INTO INDIC.SUBJECT (FID, DISPLAY_SUBJ, LAST_UPDATED_DT, FILE_SINCE_DT)
VALUES (V_COUNTER, 'Y', SYSDATE, SYSDATE);
ITERATE c1;
END IF;
END FOR;
CLOSE c1;
END

Viewing all articles
Browse latest Browse all 13329

Trending Articles