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

How many joins can you have in sql?

0 Answers  


What is Difference Between Unique and Primary Key Constraints?

0 Answers   Wipro,


What are the different types of joins and explain them briefly.

3 Answers  


what is hash join

1 Answers   NCR,


How do you use a while loop in pl sql?

0 Answers  


How much does a sql dba make? : SQL DBA

0 Answers  


Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance

5 Answers   Target,


What is delimiter sql?

0 Answers  


What is clause?

0 Answers  


What is the use of triggers?

0 Answers  


How to copy a table in another table with datas?

9 Answers  


What is difference between stored procedures and application procedures?

0 Answers  


Categories