Trigger is an event driven PL/SQL block. Event may be any DML transaction.
Cursor is a stored select statement for that current session. It will not be stored in the database, it is a logical component.
Function is a set of PL/SQL statements or a PL/SQL block, which performs an operation and must return a value.
Posted by: Girish P
Contact Girish P
cursor is a private sql work area.
Every sql statement executed
by oracle server has an individual
cursor associated with it.
Cursor are two types
Implicit cursor: Implicit cursors
are declared by pl/sql implicitly
at the time of DML statement and select statement in pl/sql including queries that returns single row.
cursor have four attributes
SQL%ROWCOUNT-Basically it returns
means number of rows
affected by present sql statement.
SQL%ISOPEN-Always evalutes false
because implicit cursor automatically closed after execution of sql statement.
SQL%FOUND-Always evalutes true
because one or more rows are affected by recent sql statement
SQL%NOTFOUND-Always evalutes true when no rows are affected by
present sql statement.
example of explicit cursor
CURSOR emp_cur IS
FETCH emp_cur INTO v_empno,v_name ;
EXIT WHEN emp_cur%ROWCOUNT>10 OR
DBMS_OUTPUT.PUT_LINE('employee_id:'||TO_CHAR(v_empno) || 'employee_name:'||'v_name');
Trigger:-Trigger is pl/sql block or
procedure that is associated with table,view,schema and database.
Execute immidiately when particular event take place.
there are two types of trigger
1.Application trigger:fires automatically when event occurs with particular application.
2.Database trigger:Fires when
data such as DML oparation occured at that time.
DML triggers are two types
statement level trigger-statement level trigger means trigger body
execute once for the triggering event.this is default.A statement level trigger fire once even no rows are affected at all.
Row level- Trigger body execute
once for each row affected by triggering event.if no rows are
affected in that case trigger body
CREATE OR REPLACE TRIGGER secure_emp
BEFORE INSERT ON employees
TO_CHAR(SYSDATE,'DY')IN('SUN','SAT') OR TO_CHAR((SYSDATE,'HH24:MI')NOT BETWEEN '08:00' AND '18:00')THEN
RAISE_APPLICATION_ERROR(-20253,'u may insert employee information at business hrs');
Posted by: Sudipta Das
Contact Sudipta Das
cursor is temporary work area in
Type of cusor:
3.Cursor for loop
4.Cursor With Parametter
5.Cursor for Update
Trigger is asscoiated with table or database event(when a table affect like dml operation that time occurs fire)
Types of Trigger:
we can write 12 types trigger
Posted by: raja
Trigger is a stored procedure that invokes automatically when the event occurs.
We can write 12 types of triggers on table and 15 types of triggers on views.
Cursor pointer or handler to the context area . 2 types of cursors are there
implicit and explicit cursors.
Posted by: Aruna
Posted by: lal bahadur chaubey
Contact lal bahadur chaubey
Trigger is a pl/sql block which is executed whenever any dml statement(insert,update,delete)issued against the table.
Cursor is a memory area in which all the statement are executed and store the result. cursor is 2 types namely implicit cursor and explicit cursor.
Implicit cursor fetches only one row (normal select into statement) where as Explicit cursor is fetching more than one row and process one by one. In explicit cursor user have to explicitily name the cursor.
Function is a named pl/sql block which is stored in database. We can invoke by calling the name of the function whenever we need. Function is always return a value.
Posted by: Vivekanandhan H
Contact Vivekanandhan H
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.