CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.

Sponsored Links

Interview Questions
Our Services

INTERVIEW QUESTIONS ORACLE PL-SQL DETAILS
Question :
What is trigger,cursor,functions in pl-sql and we need sample programs about it?

Posted by: dilson on 5/19/2013

Contact dilson Contact dilson
Category PL-SQL Interview Questions
Rating (3.5) By 56 users
Added on 5/19/2013
Views 2903
Rate it!


Answers:

Source: CoolInterview.com

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.


Source: CoolInterview.com



Posted by: Girish P

Contact Girish P Contact Girish P

Source: CoolInterview.com

Cursor
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
1. SQL%ROWCOUNT
2. SQL%ISOPEN
3. SQL%NOTFOUND
4. SQL%FOUND
SQL%ROWCOUNT-Basically it returns
number.
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
DECLARE
v_empno employees.employee_id%TYPE;
v_name employees.last_name%TYPE;
CURSOR emp_cur IS
SELECT employee_id,last_name
FROM employees
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO v_empno,v_name ;
EXIT WHEN emp_cur%ROWCOUNT>10 OR
emp_cur%NOTFOUND;

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

END LOOP;
CLOSE emp_cur;
END;

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
CREATE OR REPLACE TRIGGER secure_emp
BEFORE INSERT ON employees
BEGIN
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');
END;


Source: CoolInterview.com



Posted by: Sudipta Das

Contact Sudipta Das Contact Sudipta Das

Source: CoolInterview.com

Cursor:
cursor is temporary work area in
pl/sql.
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:
%foud
%notfound
%rowCount
%isopen

Trigger:
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

Source: CoolInterview.com



Posted by: raja

Contact raja Contact raja

Source: CoolInterview.com

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.

Source: CoolInterview.com



Posted by: Aruna

Contact Aruna Contact Aruna

Source: CoolInterview.com

DTHDTH
Source: CoolInterview.com



Posted by: lal bahadur chaubey

Contact lal bahadur chaubey Contact lal bahadur chaubey

Source: CoolInterview.com

Trigger
-------
Trigger is a pl/sql block which is executed whenever any dml statement(insert,update,delete)issued against the table.

Cursor
------
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
--------
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: CoolInterview.com



Posted by: Vivekanandhan H

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 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.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    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?

    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?
    Declare
    Cursor c1 is select * from emp FORUPDATE;
    Z c1%rowtype;
    Begin
    Open C1;
    Fetch c1 into Z;
    Commit;
    Fetch c1 in to Z;
    end;


    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 Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL PL-SQL Interview Questions & Answers

    User Options
    India News Network

    Latest 20 Questions
    Which one is the feature of Marshall's definition? a)Limited ends b)Scarce means c)Study of wealth as well as study of man d)Study of allocation of resources
    What will be the shape of PPC curve when marginal opportunity cost is constant? a)Concave b)Convex c)Backward bending d)Straight line
    A developed economy uses_____ technique in production. a)Labour intensive b)Capital intensive c)Home-based d)Traditional
    Micro economics is also known as_______: a)Public economics b)Price theory c)Income theory d)Demand theory
    Economic problem arises when: a)When wants are unlimited b)Resources are limited c)Alternative uses of resources d)All of the above
    Journal records the transactions of the firm in a: a) Analytical manner b) Chronological manner c) Periodical manner d) Summarized manner
    Capital of business is Rs. 75,000 and liability is Rs. 25,000 then total assets of business would be: a) Rs. 1,00,000 b) Rs. 15,000 c) Rs. 75,000 d) Rs. 50,000
    In which of the following cases, accounting estimates are needed? a) Employee benefit obligations b) Impairment of losses c) Inventory obsolescence d) All of the above
    What is the difference between a regular bitmap and a nine-patch image?
    What is portable wi-fi hotspot?
    What is a Sticky Intent?
    What are the core components under the Android application architecture?
    When is the best time to kill a foreground activity?
    What is a Fragment?
    What data types are supported by AIDL?
    What is AIDL?
    When does ANR occur?
    ___________ appear as a footnote below the balance sheet. a) Fictitious Assets b) Contingent Liabilities c) Current Liabilities d) Current Assets
    What is the importance of Default Resources?
    Contingent liability if becomes probable then it is _________ a) Provided in the books of A/c b) Provided in Director's report c) Shown in notes to accounts d) None of these



    Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

    MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
    MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

    GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

    IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
    IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

    SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
    SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions



    Cache = 0.804688 Seconds