Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

no data condition with dynamic result set - forum topic by j355ga

$
0
0

 

Anybody know how to detect NO DATA condition for a select in dynamic result set?  

 

This simple example detects the no condition  for the UPDATE but  the select does not generate a no data condition.

 

 

 

 

 

replace  PROCEDURE   get_id ( in  p_id char(7) )

dynamic result sets 2

 

P1: BEGIN

 

declare v_sql_sel varchar(2000);

declare v_sql_upd varchar(2000);

declare v_test integer default 1;

 

declare emp_hdr_sel cursor with return only  for s1;

declare emp_hdr_upd cursor with return only  for u1;

 

declare exit handler for not found insert into    sp_log values(current_timestamp, v_test, 'There was no data');

 

set v_sql_sel =  'select lname from  emp where id=?;';

 

set v_sql_upd =  'update   emp set lname=''FOO'' where id = ? ; ';

 

prepare s1 from v_sql_sel;

open emp_hdr_sel using p_id;

 

 set v_test =2;

 

prepare u1 from v_sql_upd;

open emp_hdr_upd using p_id;

 

END P1;

 

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles