Beruflich Dokumente
Kultur Dokumente
A function can be called from sql statements and queries while procedure can be called in a begin end
block only.
5. 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...
6. What is difference between stored procedures and application procedures,stored function and application
function?
Stored Procedure/Function is a compiled database object, which is used for fast response from Oracle
Engine.Difference is Stored Procedure must return multiple value and function must return single value .
Disadvantage:
using implicit/explicit cursors are depended by sutiation. if the result set is les than 50 or 100 records it is
better to go for implicit cursors. if the result set is large then you should use exlicit cursors. other wise it
will put burdon on cpu.
8. What is Raise_application_error ?
Raise_application_error is a procedure of package DBMS which allows to issue user_defined error
message.
9. Name the tables where characteristics of Package, procedure and functions are stored ?
These Data Base objects are stored in data dictionary. Which can be accessed by Data dict. views like
(dba_user/DBA_objects/source).
10. 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;
11. Explain how procedures and functions are called in a PL/SQL block ?
Function is called as part of an expression.
procedure is called as a PL/SQL statement
12. What is the starting "oracle error number"? 2)What is meant by forward declaration in functions?
ora 00001
Plot No: 235, Sai Cyber Hills, Survey Of India Layout, Khanamet, Madhapur,
Hyderabad - 500033
Ph: +91- 40 - 42617425/6/7
www.graymatterinformatics.com
We can handle error in plsql using exception.
Pl/sql is a portable. We can use any application so save the time and we can reuse the code in any
application.
14. 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.
15. How many types of database triggers can be specified on a table ? What are they ?
Data base triggers are mainly two types only they are
1) Statement level triggers
2) Row level triggers
18. Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no Why?With Reasons
We can not do commit,rollback and savepoints in triggers. But there is an exception for Autonomous
triggers. In autonomous triggers we can commit in between. To make a normal trigger to autonomous
trigger you have to put the below statement.
PRAGMA AUTONOMOUS_TRANSACTION;
20. In pl/sql functions what is use of out parameter even though we have return statement.
A database triggers is stored PL/SQL program unit associated with a specific database table or view. The
code in the trigger defines the action the database needs to perform whenever some database
manipulation (INSERT, UPDATE, DELETE) takes place.
23. In a Distributed Database System Can we execute two queries simultaneously ? Justify ?
As Distributed database system based on 2 phase commit, one query is independent of 2 nd query so of
course we can run.
25. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ?
Why ?
Plot No: 235, Sai Cyber Hills, Survey Of India Layout, Khanamet, Madhapur,
Hyderabad - 500033
Ph: +91- 40 - 42617425/6/7
www.graymatterinformatics.com
We can create table by using procedure using execute immediate command.
create procedure p1 is
begin
EXECUTE IMMEDIATE 'CREATE TABLE temp AS
SELECT * FROM emp ' ;
END;
27. What is difference between a Cursor declared in a procedure and Cursor declared in a package
specification ?
A cursor declared in a package specification is global and can be accessed by other procedures or
procedures in a package.
A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
29. What are the modes of parameters that can be passed to a procedure ?
34. What happens if a procedure that updates a column of table X is called in a database trigger of the same
table ?
Plot No: 235, Sai Cyber Hills, Survey Of India Layout, Khanamet, Madhapur,
Hyderabad - 500033
Ph: +91- 40 - 42617425/6/7
www.graymatterinformatics.com