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 many joins can you have in sql?
What is Difference Between Unique and Primary Key Constraints?
What are the different types of joins and explain them briefly.
what is hash join
How do you use a while loop in pl sql?
How much does a sql dba make? : SQL DBA
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
What is delimiter sql?
What is clause?
What is the use of triggers?
How to copy a table in another table with datas?
What is difference between stored procedures and application procedures?