How to get rowcount on dynamic sql?
889110Dec 7 2011 — edited Dec 8 2011Gurus, experts, and just plain people who are smarter than me. I've googled and googled and I while there are examples of how to do this, there is some complication that doesn't apply to me!
I have a PLSQL function that depends upon knowing the number of rows returned in order to figure out what to set a variable to.
E.g.:
v_sql := 'select element_id from '||v_lsidt||'_base where element_id = '||chr(39)||v_osid||chr(39);
EXECUTE IMMEDIATE v_sql
IF SQL%ROWCOUNT > 0 THEN
...
ELSE
...
END IF
Unfortunately, it seems like the rowcount is always coming back as so the code doesn't pass through the IF block. Can someone explain to me what I'm doing wrong?
Thank you.
PS - I realize this may be a common question so I apologize in advance if the answer was in plain sight and I failed to recognize it lol.