Guest User

Untitled

a guest
Jul 24th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. can we store the result of dynamic query into a variable and use it in if block?
  2. Declare
  3. v_count number
  4. v_sql varchar2(1000);
  5.  
  6. begin
  7.  
  8. v_count :='select count(*) from table_name';
  9.  
  10. Execute Immediate v_count;
  11.  
  12. if(v_count <>0) then
  13.  
  14. v_sql :='delete table_name where x=X' ;
  15.  
  16. Execute Immediate v_sql ;
  17.  
  18. End if ;
  19.  
  20. end;
  21.  
  22. Declare
  23. v_statement varchar2(32767);
  24. v_count number;
  25. v_sql varchar2(1000);
  26.  
  27. begin
  28.  
  29. v_statement :='select count(*) from table_name';
  30.  
  31. Execute Immediate l_statement into v_count;
  32.  
  33. if v_count >0 then
  34. ...
  35. end if ;
  36.  
  37. end;
Advertisement
Add Comment
Please, Sign In to add comment