For-Schleife cursor in teradata

In meinem Teradata Gespeicherte Prozedur, ich möchte eine for-Schleife cursor gegen eine dynamische sql.

Unten ist das code-snippet

SET get_exclude_condition = '';

SET colum_id = 'SELECT MIN (parent_criteria_id) ,MAX (parent_criteria_id)  FROM  arc_mdm_tbls.intnl_mtch_criteria WHERE act_ind = 1 AND criteria_typ = ''Exclude'' AND mtch_technique_id ='||mtch_technique_id||';' ;
PREPARE input_stmt FROM colum_id;
OPEN flex_cursor;
FETCH flex_cursor INTO parent_criteria_id_min , parent_criteria_id_max ;
CLOSE flex_cursor;

SET get_exclude_condition = '';

WHILE (parent_criteria_id_min <=  parent_criteria_id_max)
DO

    SET get_exclude_condition = get_exclude_condition || '(  ';

    SET for_loop_stmt = 'SELECT criteria  FROM arc_mdm_tbls.intnl_mtch_criteria WHERE act_ind = 1 AND mtch_technique_id ='||mtch_technique_id||' AND criteria_typ= ''Exclude'' AND parent_criteria_id ='||parent_criteria_id_min||';';

    FOR for_loop_rule AS c_cursor_rule CURSOR FOR 
        for_loop_stmt
    DO

Kann ich deklarieren Sie eine cursor-for-Schleife wie diese ?
Oder brauche ich so etwas nur ?

FOR for_loop_rule AS c_cursor_rule CURSOR FOR 
        SELECT rule_id 
        FROM arc_stage_tbls.assmt_scoring_rules 
        WHERE rule_typ = :v_RuleType
        ORDER BY rule_id
DO  

Ich meine, kann ich das erste Bild der dynamischen sql-und dann eine for-Schleife cursor oben, oder mit der cursor-Deklaration nur ich muss eine statische sql-Abfrage ?

Bitte klären.

InformationsquelleAutor StrugglingCoder | 2015-11-11

Schreibe einen Kommentar