Thanks!!!
I am still getting an error after dates are cast to character. Are the dates parsed differently when converted to text; is there a way to see this?
Modified script:
CREATE PROCEDURE DELCRT_ROWS
(IN tabschema VARCHAR(128), IN tabname VARCHAR(128), IN predicate VARCHAR(1000), IN date1 DATE, IN date2 DATE, IN commitcount INTEGER)
BEGIN
DECLARE SQLCODE INTEGER;
DECLARE txt VARCHAR(10000);
DECLARE stmt STATEMENT;
SET txt = 'DELETE FROM (SELECT 1 FROM "' || tabschema || '"."' || tabname || '" WHERE '
|| predicate || ' BETWEEN ' || RTRIM(CHAR(date1)) || ' AND ' || RTRIM(CHAR(date2)) || ' FETCH FIRST ' || RTRIM(CHAR(commitcount)) || ' ROWS ONLY) AS D';
PREPARE stmt FROM txt;
l: LOOP
EXECUTE stmt;
IF SQLCODE = 100 THEN LEAVE l; END IF;
COMMIT;
END LOOP;
END
@
Error message:
CALL U261251.DELCRT_ROWS('U27332','AUD_TRL_CNTL_TOT','P ROD_DT','2006-10-01','2006-10-31', 10)
SQL0401N The data types of the operands for the operation "BETWEEN" are not
compatible. SQLSTATE=42818
