- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What is trigger,cursor,functions in pl-sql and we need sample programs about it?

Answer: 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.

Category PL-SQL Interview Questions & Answers - Exam Mode / Learning Mode
Rating (1.4) By 198 users
Added on 5/19/2013
Views 4006
Rate it!
Question: What is trigger,cursor,functions in pl-sql and we need sample programs about it?

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.


Answered by: Girish P | Date: 6/6/2008 | Contact 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
1.Implicit cursor
2.Explicit cursor
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
v_empno employees.employee_id%TYPE;
v_name employees.last_name%TYPE;
CURSOR emp_cur IS
SELECT employee_id,last_name
FROM employees
OPEN emp_cur;
FETCH emp_cur INTO v_empno,v_name ;

DBMS_OUTPUT.PUT_LINE('employee_id:'||TO_CHAR(v_empno) || 'employee_name:'||'v_name');

CLOSE emp_cur;

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
1.Statementlevel trigger
2.Rowlevel trigger

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
not executed.
trigger example
RAISE_APPLICATION_ERROR(-20253,'u may insert employee information at business hrs');


Answered by: Sudipta Das | Date: 6/10/2008 | Contact Sudipta Das Contact Sudipta Das

cursor is temporary work area in
Type of cusor:
1.Implict Cursor
2.Explicit Cursor
3.Cursor for loop
4.Cursor With Parametter
5.Cursor for Update
6.Ref Cursor

Curosr Attributes:

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

Answered by: raja | Date: 11/6/2008 | Contact raja Contact 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.

Answered by: Aruna | Date: 12/2/2008 | Contact Aruna Contact Aruna

DTHDTH Source:

Answered by: lal bahadur chaubey | Date: 3/5/2010 | Contact 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. Source:

Answered by: Vivekanandhan H | Date: 5/26/2010 | Contact 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

  • 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.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no Why?With Reasons
View Answer
In pl/sql functions what is use of out parameter even though we have return statement.
View Answer
How we can create a table through procedure ?
View Answer
What is ref cursor?
View Answer
What is pl/sql?what are the advantages of pl/sql?
View Answer
State the advantage and disadvantage of Cursor?

View Answer
State the difference between implicit and explicit cursor's.

View Answer
What is difference between stored procedures and application procedures,stored function and application function?

View Answer
Explian rowid,rownum?What are the pseduocolumns we have?

View Answer
1)What is the starting "oracle error number"?
2)What is meant by forward declaration in functions?

2)What is meant by forward declaration in functions - PL-SQL Interview Questions & Answers" class="btn btn-primary btn-xs">View Answer
In a Distributed Database System Can we execute two queries simultaneously ? Justify ?

View Answer
How we can create a table in PL/SQL block. insert records into it??? is it possible by some procedure or function?? please give example...

View Answer
How to avoid using cursors? What to use instead of cursor and in what cases to do so?

View Answer
How to disable multiple triggers of a table at at a time?

View Answer
Can we declare a column having number data type and its scale is larger than pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)

View Answer
What are the Restrictions on Cursor Variables?
View Answer
What will the Output for this Coding?
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Open C1;
Fetch c1 into Z;
Fetch c1 in to Z;

View Answer
What is PL/SQL ?
View Answer
What is the basic structure of PL/SQL ?
View Answer
What are the components of a PL/SQL block ?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here - Best Freshers & Experienced Jobs Website.

View All PL-SQL Interview Questions & Answers - Exam Mode / Learning Mode

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.015625 Seconds