How can you create Cursor with parametres ?
Answers were Sorted based on User's Feedback
Answer / swapna
CREATE OR REPLACE procedure emp_disp1(DNO EMP.DEPTNO%TYPE)
is
CURSOR CN(DNO1 NUMBER) IS SELECT * FROM EMP WHERE DEPTNO =
DNO;
CV CN%ROWTYPE;
begin
IF CN%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('CURSOR ALREADY OPEN');
ELSE
OPEN CN(DNO);
DBMS_OUTPUT.PUT_LINE('CURSOR OPEN NOW');
END IF;
FETCH CN INTO CV;
WHILE CN%FOUND LOOP
dbms_output.put_line('employee
id'||' '||CV.EMPNO||'employee
name'||' '||CV.Ename||'employee
managerid'||' '||CV.mgr||'employee
salary'||' '||CV.sal||'eEMPLOYEE DEPT
ID'||CV.DEPTNO);
FETCH CN INTO CV;
END LOOP;
DBMS_OUTPUT.PUT_LINE('NUMBER OF FETCHES IS '||CN%ROWCOUNT);
CLOSE CN;
exception
when no_data_found then
dbms_output.put_line('record not existed');
when too_many_rows then
dbms_output.put_line('record not existed');
end;
/
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / madhuri
We can create cursor with parameters using parameterized
cursors.We declare the cursor in the deceleration section
with parameters.
Syntax: cursor <cursor_name>(parameters) is <select_stmt>
We pass values to these cursors while opening it.
open c1(100,'Computers');
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / amar_kondla
HI SWAPNA, I WAS C UR EXAMPLE, BUT IN PARAMETELIZED
CURSORS PARAMETERS ALWAYS IN MODE;
Is This Answer Correct ? | 0 Yes | 0 No |
How much does a sql dba make? : SQL DBA
Is sql pronounced sequel or sql?
how can you see all indexes defined for a table? : Sql dba
What is a constraint? Tell me about its various levels.
What are the types of SQL Statement?
What is correlated sub-query?
25.67,-1 Trunc = 20 Round= 30 HOW????
Are sql database names case sensitive?
How can we make an if statement within a select statement?
What is difference between inner join and cross join?
How do you write an inner join query?
What is query optimization in sql?