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

Variable results from an sql statement - response (1) by spidermonk

$
0
0
Hey Teradata Forum,   I found a work around for the above issue using the 'GET DIAGNOSTICS' function.  My problem was making sure pt_id was truly unique using a random number so I needed to cycle thru until one was found.  If the row_count returned 1(meaning 1 row was updated) I knew it was a unique number.  This is done by checking the value of t_dups.   It works for deletes, updates, inserts but not on selects.   DECLARE t_dups INTEGER DEFAULT 0;   SET sql_stmt = ' UPDATE DM_JNJCHF_TEST'|| ' SET PT_ID = ' || t_random_num || ' WHERE PAT_ID = ' || t_pat_id || ' AND (SELECT COUNT(*) FROM DM_JNJCHF_TEST' || ' WHERE PT_ID =' || t_random_num || ' ) = 0'; EXECUTE IMMEDIATE sql_stmt;   GET DIAGNOSTICS t_dups = ROW_COUNT;      

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>