How can you create Cursor with parametres ?

Answers were Sorted based on User's Feedback



How can you create Cursor with parametres ?..

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

How can you create Cursor with parametres ?..

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

How can you create Cursor with parametres ?..

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

Post New Answer

More SQL PLSQL Interview Questions

what is Hash join?how it is different from inner join?what is the sign used for inner join?(eg: like the (+) sign used for outer join)?

3 Answers   TCS,


Can we use pl sql in sql server?

0 Answers  


what's the difference between a primary key and a unique key? : Sql dba

0 Answers  


What does an inner join do?

0 Answers  


Explain how you can copy a file to file content and file to pl/sql table in advance pl/sql?

0 Answers  






Define join and name different types of joins?

0 Answers  


table - new_no old_no 2345 1234 3456 2345 5678 4567 output sud be -new_no 1234 2345 3456 4567 5678

2 Answers  


what does myisamchk do? : Sql dba

0 Answers  


What is the difference between in and between in sql?

0 Answers  


how can we know the number of days between two given dates using mysql? : Sql dba

0 Answers  


What cursor type do you use to retrieve multiple recordsets?

17 Answers   Apollo, CTS, IonIdea, Microsoft, Oracle, TCS, Vmoksha, Wipro,


What is sql integrity?

0 Answers  


Categories