Software unit testing and DB2 sql loop test code

27 June,2011 by Jack Vamvas

Software unit testing  is normally a formalised approach to test code and system implementations.

DB2 sql loop  test is  sometimes requested by developers to the  DB2 DBA .

 This code is a stored procedure the DB2 DBA can set up and test . 

The code creates a table : “test”   and a stored procedure  : “sum_mn”

 An example execute of  the code as :call sum_mn 1,1000,?

This starts from 1 loops through to 1000 and adding at every loop

#############CODE START###############################

CREATE TABLE test (num INT);

CREATE PROCEDURE sum_mn (IN p_start INT ,IN p_end INT ,OUT p_sum INT) SPECIFIC sum_mn

LANGUAGE SQL

smn: BEGIN

DECLARE v_temp INTEGER DEFAULT 0;

DECLARE v_current INTEGER;

SET v_current = p_start;

WHILE (v_current <= p_end)

DO INSERT INTO test VALUES(v_current);

SET v_temp = v_temp + v_current; SET v_current = v_current + 1; END WHILE;

SET p_sum = v_temp;

END smn;

 ######################CODE FINIS########################

 DB2 sql loop test code  is useful in performance testing and general DB2 code development

Author: Jack Vamvas(http://www.dba-db2.com)

Author: Jack Vamvas(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Software unit testing and DB2 sql loop test code

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright