Home » SQL & PL/SQL » SQL & PL/SQL » variable in clausule where
variable in clausule where [message #4087] Thu, 07 November 2002 14:31 Go to next message
sergio m
Messages: 4
Registered: November 2002
Junior Member
Hi !
I have a problem, in the sentence select i need use one variable in the clausule where, but i don't know how make, example:
select name,salary from employee
var1;

where var1 is 'where id = 15 and salary > 100'
is in a cursor.

thanks
i'm mexican, my english not is good.
Re: variable in WHERE clause [message #4088 is a reply to message #4087] Thu, 07 November 2002 14:47 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Dynamic SQL.

create or replace procedure my_proc (p_where in varchar2)
is
  type rc is ref cursor;
  v_cursor  rc;
begin
  open v_cursor for 'select name, salary from employee ' || p_where;
  loop
    fetch v_cursor into x, y;
    exit when v_cursor%notfound;
    -- do something
  end loop;
  close v_cursor;
end;
Previous Topic: loops
Next Topic: ...wanted a SQL query
Goto Forum:
  


Current Time: Mon Apr 29 04:18:11 CDT 2024