Hello Experts,
I am trying to range partition TARGET_TABLE based on values in my PARTITION_MAP table. I have written a HANA procedure for the same.
ALTERTABLE MY_SCHEMA.TARGET_TABLE PARTITIONBY RANGE (PARTITION_ID) (PARTITIONVALUE = 1, PARTITION OTHERS);
CREATEPROCEDURE add_partitions LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE v_statement VARCHAR(500);
DECLARECURSOR partition_map_cursor FOR
SELECTdistinct PARTITION_RANGE from MY_SCHEMA.PARTITION_MAP WHERE PARTITION_RANGE <> 1 ORDERBY PARTITION_RANGE ASC;
FOR cur_rec as partition_map_cursor DO
v_statement := 'ALTER TABLE MY_SCHEMA.TARGET_TABLE ADD PARTITION VALUE = ' || cur_rec.PARTITION_RANGE;
EXEC v_statement;
ENDFOR;
END;
CALL add_partitions();
And procedure execution fails with the following error.
Could not execute 'CALL add_partitions()' in 1.041 seconds .
[129]: transaction rolled back by an internal error: [129] "MY_SCHEMA"."ADD_PARTITIONS": line 11 col 11 (at pos 499): [129] (range 3): transaction rolled back by an internal error: column store error: fail to add partition: [5520] part of split table does not exist;part of split table does not exist;MY_SCHEMA:TARGET_TABLE,part=4,Error when splitting part.
Partition queries are getting generated properly and I could execute the generated query outside this procedure successfully. But the same query fails if I execute it through EXEC or EXECUTE IMMEDIATE.
Have i missed anything in the procedure. Please advise.
Thanks in advance.
Regards,
Suren.