Thanks a lot for your suggestion it worked succesfully.But I am trying to modify it to delete a particular row depending on the where condition.
I just want to insert this statement
ALTER TABLE schema.tablename NOT LOGGED INITIALLY;
delete from schema.tablename where month = 200512 ;
(SET stmt1 = 'ALTER TABLE '|| p_TableName ||' ACTIVATE NOT LOGGED INITIALLY ';
PREPARE s2 FROM stmt;
EXECUTE s2;
SET stmt2 = 'DELETE FROM '|| p_TableName ||' WHERE MONTH = ' || 'P_MONTH';
PREPARE s3 FROM stmt2;
EXECUTE s3
It compiles without any error but it ends with TABLENAME undefined.
Does having 2 different statement on the same table ina procedure lock the table that it canot be accesed twice i mean one for alter and the other for delete.
CREATE PROCEDURE SCHEMA.SP_Empty_Table (IN p_TableName VARCHAR(50), OUT p_Rows INTEGER, OUT RtnCode INTEGER )
------------------------------------------------------------------------
-- SQL Stored Procedure
-----------------------------------------------------------------------
LANGUAGE SQL
SPECIFIC EMPTY_TABLE1
P1: BEGIN
declare stmt varchar(150);
-- Declare cursors for result set and output parameter data
SET stmt = 'ALTER TABLE '|| p_TableName ||' ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE';
PREPARE s1 FROM stmt;
EXECUTE s1;
COMMIT;
END P1