Here's that procedure, again, pardon any typos/messiness/pseudo-code as I can't cut and paste.
CREATE PROCEDURE BLD_STMT_TBL(IN tbl varchar(256), IN sch varchar(256))
DECLARE dsql varchar(1024);
DECLARE xstchk varchar(256);
SELECT MAX(table_name) from TABLES where TABLE_NAME = 'STMT_TBL';
IF xstchk = 'STMT_TBL' THEN
dsql := 'DROP TABLE STMT_TBL';
exec dsql;
END IF;
dsql := *Big ugly sql statement that creates and populates STMT_TBL
exec dsql;
end;
The bottom exec is where the compiler throws the error, although as I mentioned before, both procedures work completely fine if I call them directly, one after another. The error only occurs when I attempt to call both procedures from an outer procedure.
Also, if I comment out the bottom exec, the top exec works fine. It doesn't give me the recursive error when I drop the STMT_TBL, but when I recreate STMT_TBL.
For reference, all the OUTER procedure does is:
1.Accept an INPUT_TABLE_NAME and INPUT_SCHEMA_NAME
2.Uppercase both
3. Does the same XSTCHK as above to make sure STMT_TBL exists, and if it does delete some rows from it via dynamic sql (redundant with the later drop, but it's a work in progress!)
4. Call BLD_STMT_TBL
5. Does a similar XSTCHK to make sure a TARGET_TABLE exists, and if does deletes some rows from it via dynamic sql
6. Call BLD_TBL (which populates that TARGET_TABLE using the dynamic SQL statements that are in STMT_TBL)
There is definitely no "cyclical dependency", as the error message is saying, but HANA obviously objects to something......