Home » SQL & PL/SQL » SQL & PL/SQL » how to create cursor with bind variables
how to create cursor with bind variables [message #36192] Fri, 09 November 2001 01:14 Go to next message
srin
Messages: 3
Registered: November 2001
Junior Member
Hi,
i have a procedure as

procedure test(stime in varchar2,dtime in varchar2) as
sttime: = to_date(stime,'dd/mm/yyyy hh24:mi');
endtime: = to_date(dtime,'dd/mm/yyyy hh24:mi');

select col1,col2 from tab where
col3>= sttime and col4<= endtime

How do i make this select statement as a cursor.

Any help is appreciated.

Srin

----------------------------------------------------------------------
Re: how to create cursor with bind variables [message #36196 is a reply to message #36192] Fri, 09 November 2001 05:00 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
procedure test(stime in varchar2,dtime in varchar2) as
sttime date: = to_date(stime,'dd/mm/yyyy hh24:mi');
endtime date: = to_date(dtime,'dd/mm/yyyy hh24:mi');
cursor c1 IS SELECT col1,col2
where col3>=sttime and col4<=endtime;
begin

---

end;

----------------------------------------------------------------------
Re: how to create cursor with bind variables [message #36209 is a reply to message #36196] Fri, 09 November 2001 11:23 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Even better - user cursor parameters - it helps keep the cursor more efficient in multi user environments:

procedure test(stime in varchar2,dtime in varchar2) as
sttime date: = to_date(stime,'dd/mm/yyyy hh24:mi');
endtime date: = to_date(dtime,'dd/mm/yyyy hh24:mi');
cursor c1 (STTIME IN DATE, ENDTIME IN DATE)IS SELECT col1,col2
where col3>=sttime and col4<=endtime;
begin

---

end;

----------------------------------------------------------------------
Previous Topic: how to create a database link
Next Topic: how to insert data from ref table(collection) into a table in a loop
Goto Forum:
  


Current Time: Thu Mar 28 17:47:42 CDT 2024