hi****@gmail.com wrote:
Thanks Serge for your tip.
Correction: The import/load into is not into table1(T1) but into
table2(T2). Is there no option from task center or some script to
execute this kind of a logic?
I want to check a table say T1 if it contains records, and if so, then
delete rows in the huge table say T2(I wanted to accomplish this
quicker by load replace with empty file or with "alter table T2
activate not logged initially with empty table"). Then I want to insert
records from T3 to T2.
Ah.. so in other words this is already teh nth interation of spinning
your tires in the sand ;-)
Let's back up and start this from scratch:
1. You cannot do DDL (such as ALTER TABLE in a standalone BEGIN ATOMIC)
2. Knowing that you CAN do ALTER TABLE in an SQL Procedure
using dynamic SQL (Is that the missing piece??).
So:
--#SET TERMINATOR @
CREATE PROCEDURE proc()
BEGIN
DECLARE alterstr VARCHAR(1000);
IF EXISTS(SELECT 1 FROM T) THEN
SET alterstr = 'ALTER TABLE S ACTIVATE NOT LOGGED '
||'INITIALLY WITH EMPTY TABLE';
EXECUTE IMMEDIATE alterstr;
INSERT INTO S SELECT * FROM T;
COMMIT;
END IF;
END
@
--#SET TERMINATOR ;
Now if you want to do a LOAD instead of a NOT LOGGED INSERT you will
need to write a C Procedure and use the LAOD API.
Eventually DB2 will support LOAD through the admin procedure....
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab