Hi
I need to create a table, that might already exist.
I would like to have a call to procedure , with the table name, so that procedure will DROP the table (exists or not) and let me continue with the CREATE
I worte a code likes this:
the procedure is called like this:
When I run it foreground - it works perfect. (if the table exists, it drops it and continue with the create - if it does not, it ignores the *FILE not found error and continue with the create
When I run it in job (with same libl/jobd etc.) - the process work fine only if the table already exists. If it does not, SQL error - *FILE NOT FOUND is received.
my question:
1. why good in foreground and bad in batch
2. can I have a sample other procedure to drop a table regarding its existance and let the create continue
thanks !!!
I need to create a table, that might already exist.
I would like to have a call to procedure , with the table name, so that procedure will DROP the table (exists or not) and let me continue with the CREATE
I worte a code likes this:
Code:
CREATE PROCEDURE DRPTBLRI (P_TBL_NAME CHAR(10))
LANGUAGE SQL
BEGIN
DECLARE M_SQL_STM CHAR(512) NOT NULL DEFAULT '';
DECLARE AT_END SMALLINT NOT NULL DEFAULT 0 ;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
SET AT_END = 1;
SET M_SQL_STM = 'DROP TABLE ' CONCAT P_TBL_NAME;
EXECUTE IMMEDIATE M_SQL_STM;
END
Code:
CALL DRPTBLRI('MSERNTOT');
CREATE TABLE MSERNTOT
( .....
When I run it in job (with same libl/jobd etc.) - the process work fine only if the table already exists. If it does not, SQL error - *FILE NOT FOUND is received.
my question:
1. why good in foreground and bad in batch
2. can I have a sample other procedure to drop a table regarding its existance and let the create continue
thanks !!!




Comment