Dynamically Change SQLText Inside Procedure


Dynamically Change SQLText Inside Procedure


I am a newbee to Teradata.Currently using version 14 for developmental work.

Q1 I am working on a stored procedure that need to accept two Input parameters ID1 and ID2 from a Stage table that will be populated using another SQL.

Can I use Cursor logic to accept the values from this table and pass it to my procedure.The procedure need to be invoked N number of times depending upon the ID1 and ID2 values

Is there an efficient way to acheive this.

Q2 Once I substitute the value to procedure,internally a function is invoked which returns a SQL statement.This function should not be changed instead I need to change the entire select clause(No change to Where condition).How this can be achieved?Any existing posts or reference available

Q3 The SQL Resultset need to be stored and executed to insert records to another table

Can I use dbc.execSQL(variable) to achieve this

Any help is appreciated



Tags (1)