
//Alias Depends On Table
CREATE TABLE "alias_dep_tb1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO
CREATE ALIAS "alias_dep_tb2"
  FOR "alias_dep_tb1"
GO

//Alias Depends On Alias
CREATE TABLE "alias_dep_alias1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO
CREATE ALIAS "alias_dep_alias2"
  FOR "alias_dep_alias1"
GO

CREATE ALIAS "alias_dep_alias3"
  FOR "alias_dep_alias2"
GO
//Alias depend on Sequence=Not Extracted in schema sync
CREATE SEQUENCE "Alias_dep_seq1"
 AS INTEGER
 CACHE 20
 MINVALUE 0
 MAXVALUE 9999
 ORDER
GO
CREATE ALIAS "Alias_dep_seq2"
  FOR SEQUENCE "Alias_dep_seq1"
GO
//Alias Depends On View
CREATE TABLE "alias_dep_view1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO
CREATE VIEW "alias_dep_view2"
AS
SELECT * FROM "alias_dep_view1"
GO
CREATE ALIAS "alias_dep_view3"
        FOR "alias_dep_view2"
GO

//Index Depends On Table
CREATE TABLE "index_dep_tb1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE INDEX "index_dep_tb2"
        ON "index_dep_tb1"("Col1" ASC)
GO

//Sequence depends On User Defined Data Types
CREATE DISTINCT TYPE "seq_dep_UDDt1" AS INTEGER
	WITH COMPARISONS

GO

CREATE SEQUENCE "seq_dep_UDDt2" AS "DB_LEFT"."seq_dep_UDDt1"
        START WITH 1
        INCREMENT BY 1
        MAXVALUE 2147483647
        MINVALUE 1
        NO CYCLE
        CACHE 20
        NO ORDER
GO
//Stored Procedure Depends On Alias
CREATE TABLE "sp_dep_alias1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO
CREATE ALIAS "sp_dep_alias2"
  FOR "sp_dep_alias1"
GO
CREATE PROCEDURE  "sp_dep_alias3"
(IN val varchar(20))
 LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_alias2" ("Col1")    
      VALUES (val);
END
GO
///Stored Procedure Depends On User Defines Functions
CREATE TABLE "sp_dep_UDF1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE FUNCTION "sp_dep_UDF2"( num1 Integer, num2 Integer)
RETURNS INTEGER
SPECIFIC "sp_dep_UDF2"
BEGIN ATOMIC
RETURN num1 + num2;
END
GO

CREATE OR REPLACE PROCEDURE "sp_dep_UDF3"()
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_UDF1" ("Col1")   
     VALUES ("DB_LEFT"."sp_dep_UDF2"(1,5));
END
GO
//Stored Procedure Depends On Sequences
CREATE TABLE "sp_dep_seq1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
 GO

CREATE SEQUENCE "sp_dep_seq2"
 AS INTEGER
 CACHE 20
 MINVALUE 0
 MAXVALUE 9999
 ORDER
GO

CREATE PROCEDURE "sp_dep_seq3"()
BEGIN ATOMIC
INSERT INTO "sp_dep_seq1"("Col1") VALUES ("sp_dep_seq2".NEXTVAL);
END
GO
//Stored Procedure Depends On Stored Procedure
CREATE TABLE "sp_dep_sp1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE OR REPLACE PROCEDURE "sp_dep_sp2"(IN val VARCHAR(10))
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_sp1" ("Col1")   
     VALUES (val);
END
GO

CREATE OR REPLACE PROCEDURE "sp_dep_sp3"(IN val VARCHAR(10))
LANGUAGE SQL
BEGIN ATOMIC
CALL "DB_LEFT"."sp_dep_sp2"(val);
END
GO
//Stored Procedure Depends On Table
CREATE TABLE "sp_dep_tb1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
 GO

CREATE OR REPLACE PROCEDURE "sp_dep_tb2"
(IN val varchar(20))
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_tb1" ("Col1")   
     VALUES (val);
END
GO
//Stored Procedure Depends On UDDT
CREATE TABLE "sp_dep_udd1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE DISTINCT TYPE "sp_dep_udd2" AS VARCHAR(25) 	WITH COMPARISONS
GO

CREATE OR REPLACE PROCEDURE "sp_dep_udd3"
(INOUT val "DB_LEFT"."sp_dep_udd2")
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_udd1" ("Col1")   
     VALUES (val);
END
GO
//Stored Procedure Depends On View
CREATE TABLE "sp_dep_view1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE VIEW "sp_dep_view2"
AS
SELECT * FROM "sp_dep_view1"
GO

CREATE OR REPLACE PROCEDURE "sp_dep_view3"()
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_view2" ("Col1")   
     VALUES ('Nilesh');
END
GO
//Table Depends On Table
CREATE TABLE "tb_dep_tb1"  (
  "Col1" INTEGER NOT NULL,
  "Col2" VARCHAR(25)
  )
GO
CREATE TABLE "tb_dep_tb2"  (
  "Col1" INTEGER NOT NULL,
  "Col2" VARCHAR(25)
  )
GO
ALTER TABLE "tb_dep_tb2"
  ADD CONSTRAINT "tb_dep_tb2_uk"
  UNIQUE ("Col1")
GO
ALTER TABLE "tb_dep_tb1"
        ADD CONSTRAINT "tb_dep_tb1_fk"
        FOREIGN KEY("Col1")
        REFERENCES "tb_dep_tb2"("Col1")
        NOT ENFORCED 
        DISABLE QUERY OPTIMIZATION 
GO
//Table Depends On UDDT
CREATE DISTINCT TYPE "tb_dep_udt1" AS VARCHAR(25)
    WITH COMPARISONS 
GO
CREATE TABLE "tb_dep_udt2"  ( 
    "Col1"    INTEGER NOT NULL,
    "Col2"   "DB_LEFT"."tb_dep_udt1" 
    )
GO
//Trigger Depends On Alias
CREATE TABLE "trig_dep_alias1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO
CREATE ALIAS "trig_dep_alias2"
  FOR "trig_dep_alias1"
GO
CREATE TRIGGER "trig_dep_alias3"
AFTER DELETE ON "trig_dep_alias2"
 FOR EACH ROW MODE DB2SQL
   UPDATE "trig_dep_alias2" SET "Col1" = 'RAM' WHERE "Col1" = 'RAVI'
GO
//Trigger Depends On Sequence
CREATE SEQUENCE "trig_dep_seq1"
 AS INTEGER
 CACHE 20
 MINVALUE 0
 MAXVALUE 9999
 ORDER
GO

CREATE TABLE "trig_dep_seq2"  (
  "Col1" INTEGER NOT NULL,
  "Col2" VARCHAR(25)
  )
GO

CREATE OR REPLACE TRIGGER "trig_dep_seq3"
AFTER UPDATE ON "trig_dep_seq2"
FOR EACH ROW
BEGIN
INSERT INTO "trig_dep_seq2" ("Col1") VALUES ("trig_dep_seq1".nextVal);
END
GO
//Trigger Depends On Stored Procedure
CREATE TABLE "trig_dep_sp1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE OR REPLACE PROCEDURE "trig_dep_sp2"(IN val VARCHAR(10))
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "trig_dep_sp1" ("Col1")   
     VALUES (val);
END
GO

CREATE TRIGGER "trig_dep_sp3"
AFTER DELETE ON "trig_dep_sp1"
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL "DB_LEFT"."trig_dep_sp2"('RAM');
END
GO
//Trigger Depends On Table
CREATE TABLE "trig_dep_tb1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE OR REPLACE TRIGGER "trig_dep_tb2"
AFTER UPDATE ON "trig_dep_tb1"
FOR EACH ROW
BEGIN
INSERT INTO "trig_dep_tb1" ("Col1") VALUES ('RAVI');
END
GO
//Trigger Depends On UDF
CREATE TABLE "trig_dep_udf1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE FUNCTION "trig_dep_udf2"( val VARCHAR(50))
RETURNS VARCHAR(50)
SPECIFIC "trig_dep_udf2"
BEGIN ATOMIC
RETURN val;
END
GO

CREATE TRIGGER "trig_dep_udf3"
AFTER INSERT ON "trig_dep_udf1"
FOR EACH STATEMENT MODE DB2SQL
UPDATE "trig_dep_udf1" SET "Col1" = "DB_LEFT"."trig_dep_udf2"('RAVI')
GO

//Trigger Depends On View
CREATE TABLE "trig_dep_view1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE VIEW "trig_dep_view2"
AS
SELECT * FROM "trig_dep_view1"
GO

CREATE TRIGGER "trig_dep_view3"
AFTER INSERT ON "trig_dep_view1"
FOR EACH STATEMENT MODE DB2SQL
UPDATE "trig_dep_view2" SET "Col1" = 'RAVI'
GO

///User Defined Functions Depends On Alias
CREATE TABLE "udf_dep_alias1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE ALIAS "udf_dep_alias2"
  FOR "udf_dep_alias1"
GO

CREATE OR REPLACE FUNCTION "udf_dep_alias3"()
  RETURNS INTEGER
  LANGUAGE SQL
  RETURN SELECT COUNT("Col1") FROM "udf_dep_alias2"
GO
//User Defined Functions Depends On Sequence
CREATE SEQUENCE "udf_dep_seq1"
 AS INTEGER
 CACHE 20
 MINVALUE 0
 MAXVALUE 9999
 ORDER
GO

CREATE FUNCTION "udf_dep_seq2"()
    RETURNS INTEGER
BEGIN ATOMIC
    DECLARE VAR1 INTEGER;
    SET VAR1  = "udf_dep_seq1".NEXTVAL;
    RETURN VAR1;
END
GO
//User Defined Functions Depends On Stored Procedure
CREATE TABLE "udf_dep_sp1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE OR REPLACE PROCEDURE "udf_dep_sp2"(IN val VARCHAR(10))
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "udf_dep_sp1" ("Col1")   
     VALUES (val);
END
GO

CREATE FUNCTION "udf_dep_sp3"()
   RETURNS VARCHAR(10)
   LANGUAGE SQL
   MODIFIES SQL DATA
BEGIN
   DECLARE VAR1 VARCHAR(10);
   SET VAR1 = 'RAM';
   CALL "DB_LEFT"."udf_dep_sp2"(VAR1);
   RETURN VAR1;
END
GO
//User Defined Functions Depends On Table
CREATE TABLE "udf_dep_tb1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE FUNCTION "udf_dep_tb2"()
RETURNS TABLE ("Col1" VARCHAR(25))
   LANGUAGE SQL
   BEGIN ATOMIC
   RETURN
     SELECT "Col1" FROM "udf_dep_tb1";
   END
GO
//User Defined Functions Depends On User Defined Data Type
CREATE DISTINCT TYPE "udf_dep_udt1" AS INTEGER
GO

CREATE FUNCTION "udf_dep_udt2"()
RETURNS "DB_LEFT"."udf_dep_udt1"
   BEGIN
   RETURN 100;
   END
GO
//User Defined Functions Depends On User Defined Functions
CREATE FUNCTION "udf_dep_udf1"( num1 Integer, num2 Integer)
RETURNS INTEGER
SPECIFIC "DB_LEFT"."udf_dep_udf1"
BEGIN ATOMIC
RETURN num1 + num2;
END
GO

CREATE FUNCTION "udf_dep_udf2"()
RETURNS INTEGER
BEGIN
   RETURN "DB_LEFT"."udf_dep_udf1"(1,4);
END
GO
//User Defined Functions Depends On View
CREATE TABLE "udf_dep_view1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE VIEW "udf_dep_view2"
AS
SELECT * FROM "udf_dep_view1"
GO

CREATE FUNCTION "udf_dep_view3"()
RETURNS TABLE ("Col1" VARCHAR(25))
  LANGUAGE SQL
  RETURN
    SELECT "Col1" FROM "udf_dep_view2"
GO
//View Depend On Alias
CREATE TABLE "view_dep_alias1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
GO

CREATE ALIAS "view_dep_alias2"
  FOR "view_dep_alias1"
GO

CREATE VIEW "view_dep_alias3"
AS
SELECT * FROM "view_dep_alias2"
GO
//View Depend On Table
CREATE TABLE "view_dep_tb1"  ( 
    "Col1"    VARCHAR(25) NOT NULL 
    )
GO
CREATE VIEW "view_dep_tb2"
AS
SELECT * FROM "view_dep_tb1"
GO
//View Depends On View
CREATE TABLE "view_dep_view1"  ( 
    "Col1"    VARCHAR(25) NOT NULL 
    )
GO

CREATE VIEW "view_dep_view2"
AS
SELECT * FROM "view_dep_view1"
GO

CREATE VIEW "view_dep_view3"
AS
SELECT * FROM "view_dep_view2"
GO

//Global temp table
//View depend on GTT
CREATE GLOBAL TEMPORARY TABLE "view_dep_GTT1"  ( 
"c1" VARCHAR(25),
"c2" VARCHAR(25),
"c3" VARCHAR(25) 
)
IN "TBSP_TEMP_VR_PROT"
ON COMMIT DELETE ROWS
GO
 
CREATE VIEW "DB_LEFT"."view_dep_GTT2"
AS 
SELECT "c1","c2" FROM "DB_LEFT"."view_dep_GTT1"
GO

//Alias depend on GTT

CREATE GLOBAL TEMPORARY TABLE "alias_dep_GTT1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
  IN "TBSP_TEMP_VR_PROT"
  ON COMMIT DELETE ROWS
  GO
GO
CREATE ALIAS "alias_dep_GTT2"
  FOR "alias_dep_GTT1"
GO

////Index depend on GTT
CREATE GLOBAL TEMPORARY TABLE "index_dep_GTT1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
  IN "TBSP_TEMP_VR_PROT"
  ON COMMIT DELETE ROWS
  GO
GO

CREATE INDEX "index_dep_GTT2"
        ON "index_dep_GTT1"("Col1" ASC)
GO

//Procedure depend on GTT

CREATE GLOBAL TEMPORARY TABLE "sp_dep_GTT1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
  IN "TBSP_TEMP_VR_PROT"
  ON COMMIT DELETE ROWS
  GO
 GO

CREATE OR REPLACE PROCEDURE "sp_dep_GTT2"
(IN val varchar(20))
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO "sp_dep_GTT1" ("Col1")   
     VALUES (val);
END
GO

/////Trigger depend on GTT
CREATE GLOBAL TEMPORARY  TABLE "trig_dep_GTT1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
  IN "TBSP_TEMP_VR_PROT"
  ON COMMIT DELETE ROWS
  GO
GO

CREATE OR REPLACE TRIGGER "trig_dep_GTT2"
AFTER UPDATE ON "trig_dep_GTT1"
FOR EACH ROW
BEGIN
INSERT INTO "trig_dep_GTT1" ("Col1") VALUES ('RAVI');
END
GO

//Function depend on GTT
CREATE GLOBAL TEMPORARY TABLE "udf_dep_GTT1"  (
  "Col1"   VARCHAR(25) NOT NULL
  )
  IN "TBSP_TEMP_VR_PROT"
  ON COMMIT DELETE ROWS
  GO
GO

CREATE FUNCTION "udf_dep_GTT2"()
RETURNS TABLE ("Col1" VARCHAR(25))
   LANGUAGE SQL
   BEGIN ATOMIC
   RETURN
     SELECT "Col1" FROM "udf_dep_GTT1";
   END
GO
