karan666

getproductdetails

Jul 12th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. create or replace procedure getproductdetails(p_colname varchar2, p_value number)
  2. is
  3. v_column_exists number :=0;
  4. cursor c1 is select * from product where p_colname = p_value;
  5. myrow c1%rowtype;
  6. BEGIN
  7. select count(*) into v_column_exists
  8. from user_tab_cols
  9. where column_name = p_colname and table_name = 'PRODUCT';
  10.  
  11. if(v_column_exists > 0) then
  12. open c1;
  13. loop
  14. fetch c1 into myrow;
  15. exit when c1%notfound;
  16. dbms_output.put_line(myrow.prod_name || ' ' || myrow.prod_cost);
  17. end loop;
  18. else
  19. dbms_output.put_line('Column Not Found');
  20. end if;
  21. end getproductdetails;
Add Comment
Please, Sign In to add comment