Upload
chandu-babu
View
232
Download
2
Embed Size (px)
Citation preview
8/3/2019 1-PLSQL Interview 3680
1/40
A FUNCTION is always returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.
A function can be called from sql statements and queries while procedure can be called in abegin end block only.
Posted by: Jyoti
Contact Jyoti
In case of function,it must have
return type.
In case of procedure,it may or may n't have return type.
In case of function, only it takes IN parametersIN case of procedure
only it take IN,OUT,INOUT parameters..
Posted by: sudipta das
Contact sudipta das
A function always return a values while procedure can return one or more values through
Parameters.
A function can call directly by sql statement like select func_name from dual while procedure
cannot.
Posted by: Madhavi
Contact Madhavi
A FUNCTION always returns a value using the return statement.
And a FUNCTION can also use OUT parameter to return a value. But Return statment must
be there.
A PROCEDURE may return one or more values through parameters or may not return at all.
A function can be called from sql stmt and pl/sql stmt.
A procedure can be called within pl/sql stmt.
Page 1 of 5What is difference between a PROCEDURE & FUNCTION ?
3/6/2010http://www.coolinterview.com/interview/3 680/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3680/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3680/8/3/2019 1-PLSQL Interview 3680
2/40
In case of function,it must have
return type.
In case of procedure, it don't need return keyword.
Posted by: RISHI RAW AT
Contact RISHI RAWAT
Functions and Procedures both can return values using OUT parameter.
But Functions has return clause to return value and Procedures does not have return
statement.
Functions can be used in the sql statement and can be used as the part of the expression butProcedures can't be used.
Posted by: Sanjay Patel
Contact Sanjay Patel
Function can have both IN and OUT parameter.
Procedure cannot have return type but may return value through OUT parameter.
Posted by: Always Learner
Contact Always Learner
FUNCTION:
-It must have return type.
-It mainly used for calculation purpose.-It is part of PL/SQL block.(that is return value to block for exection of remaining code)
PROCEDURE:-It may or may not return value.
-It is mainly to perform a task.
-It is a complete PL/SQL block.
-It is used to perform DML operation.
Page 2 of 5What is difference between a PROCEDURE & FUNCTION ?
3/6/2010http://www.coolinterview.com/interview/3 680/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3680/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3680/8/3/2019 1-PLSQL Interview 3680
3/40
Posted by: Bharadwaj
Contact Bharadwaj
procedure is called as part of a statement..function is called as part of an expression.
There are some purity level for a function..procedure dont have such restrictions.
Posted by: Bikash
Contact Bikash
We use function when we wnt to compute or calculate , where as procedure use for an action
Posted by: shashank gautam
Contact shashank gautam
Difference Between Function and Procedure
1.Function get terminated if error occure while Procedure continue.
2. Function compiled every time on calling but Procedure compiled one time and stored in
compiled format for furthur use.
Posted by: Md Raquib Alam
Contact Md Raquib Alam
1) Function has to Return One Value. Howecer procedure may or may not return any
values.we can return the values via procedure using OUT/IN OUT varaibles.
2)Unlike Procedures We can call function in a Select statement. Exception being we can't use
those functions in select which has OUT varaibles.
3) We can call functions during declaration itself. e.g
declarex number := func();
-----
that is all i know.
Posted by: Jaidev Thakur
Page 3 of 5What is difference between a PROCEDURE & FUNCTION ?
3/6/2010http://www.coolinterview.com/interview/3 680/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3680/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3680/8/3/2019 1-PLSQL Interview 3680
4/40
Contact Jaidev Thakur
Functions
Compute some value
Should return a value
It must return only one value
Not possible to use OUT and IN OUT parameters, only IN parameter is allowed.
We can able to call functions in SELECT statement
Posted by: priya
Contact priya
Functions
Compute some value
Should return a value
It must return only one value
Not possible to use OUT and IN OUT parameters, only IN parameter is allowed.
We can able to call functions in SELECT statement
Procedures
Do some actions
May return a value or may not
Possible to return more than one value
Possible to use IN, OUT and IN OUT parameters
We cannot able to call in SELECT statement
Posted by: priya
Contact priya
Page 4 of 5What is difference between a PROCEDURE & FUNCTION ?
3/6/2010http://www.coolinterview.com/interview/3 680/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3680/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3680/8/3/2019 1-PLSQL Interview 3680
5/40
function is a collection of sql and plsql statments
in function we can assign the return type dataype
in procedure we can not assign the return type datatype
with using function we can return only one output.
wih using procedure we can return multiple output using parameters.in function whenever declaring a variable it's type of in parameter
in procedure variable type is in inout out
Posted by: abhay
Contact abhay
Procedures:
1. Execute as a PL/SQL statement.
2. Do not contain RETURN clause in the header.
3. Can return none, one, or many values.
4. Can contain a RETURN statement.
Function:
1. Invoke as part of an expression
2. Must contain a RETURN clause in the header3. Must return a single value
4. Must contain at least one RETURN
Page 5 of 5What is difference between a PROCEDURE & FUNCTION ?
3/6/2010http://www.coolinterview.com/interview/3 680/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3680/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3680/8/3/2019 1-PLSQL Interview 3680
6/40
Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue
an user_defined error messages from stored sub-program or database
trigger.
RAISE_APPLICATION_ERROR is a
procedure of package DBMS which
allows to issue user_defined errormessage.
Posted by: sudipta das
Contact sudipta das
The RAISE_APPLICATION_ERROR is a procedure defined by Oracle that allows the developerto raise an exception and associate an error number and message with the procedure other
than just Oracle errors.
Posted by: Moumita Nandi
Contact Moumita Nandi
It is Its a STANDARD procedure to communicate with a pre defined exception interactively by
returning a nonstandard error code and error message.
error_number : between -20000 to -20999
message : 2048 bytes
This can be used in both execution and exception setion;
Ex: 1 :
.....BEGIN
...
delete from employeeswhere manager_id = v_mgr;
if SQL%NOTFOUND then
RAISE_APPLICATION_ERROR(-20020,'This is not a valid manager');end if;
....
---------------------------
ex:2 :
......
EXCEPTION
when NO_DATA_FOUND then
Page 1 of 2What is Raise_application_error ?
3/6/2010http://www.coolinterview.com/interview/3 684/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3684/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3684/8/3/2019 1-PLSQL Interview 3680
7/40
RAISE_APPLICATION_ERROR(-20201,'manager is not a valid employee');
END;
Page 2 of 2What is Raise_application_error ?
3/6/2010http://www.coolinterview.com/interview/3 684/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3684/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3684/8/3/2019 1-PLSQL Interview 3680
8/40
User_objects, User_Source and User_error.
user_source,user_objects
Posted by: madhavi
Contact madhavi
characteristics of DB objects are stored in data dictionary. Which can be accessed by Data
dict. views like (user/all/DBA_objects/source).
Posted by: pankaj
Contact pankaj
user_source,user_objects
Posted by: suvrat
Contact suvrat
Page 1 of 1Name the tables where characteristics of Package, procedure and functions are stored ?
3/6/2010http://www.coolinterview.com/interview/3 669/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3669/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3669/8/3/2019 1-PLSQL Interview 3680
9/40
Stored procedures are sub programs stored in the database and can be called & execute
multiple times where in an application procedure is the one being used for a particular
application same is the way for 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 .
Posted by: Himanshu Kumar Tripathi
Contact Himanshu Kumar Tripathi
Procedure:-
Execute as a PL/SQLstatement,No RETURN clause in
the header,Can return none, one,
or many values,Can contain a RETURNstatement
Function:-Invoke as part of an
expression,Must contain a RETURNclause in the header,Must return a single value,Must contain at least one RETURN statement
Posted by: Dev
Contact Dev
Stored procedures are sub programs stored in the database and can be called & executemultiple times where in an application procedure is the one being used for a particular
application same is the way for 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 .
Posted by: kiran
Contact kiran
The basic difference between function and procedure is that a procedure can never be used
in a sql statement while a function can be used
Page 1 of 2What is difference between stored procedures and application procedures,stored function ...
3/6/2010http://www.coolinterview.com/interview/1 0954/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10954/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10954/8/3/2019 1-PLSQL Interview 3680
10/40
Posted by: paritosh
Contact paritosh
Difference between Stored Procedure and Application Procedure:
Stored Procedure is a named PLSQL block that will be compiled and used for further use. If
maintained across Servers, they can be used for different applications and Users. ApplicationProcedures are the one which will be used for local apps, this can be called local block of
code. Apart from technical characteristics, same will apply to the differences between Stored
Functions and Application Functions.Difference between Procedures and Functions:
a. Functions can be used in a select statement where as procedures cannot
b. Procedure takes both input and output parameters but Functions takes only inputparameters
c. Functions cannot return values of type text, ntext, image & timestamps where as
procedures can
d. Functions can be used as user defined datatypes in create table but procedures cannot***Eg:-create table (name varchar(10),salary getsal(name))
Here getsal is a user defined function which returns a salary type, when table is created no
storage is allotted for salary type, and getsal function is also not executed, But when we are
fetching some values from this table, getsal function get?s executed and the return
Type is returned as the result set.
Page 2 of 2What is difference between stored procedures and application procedures,stored function ...
3/6/2010http://www.coolinterview.com/interview/1 0954/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10954/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10954/8/3/2019 1-PLSQL Interview 3680
11/40
Implicit Cursor are declared and used by the oracle internally. whereas the explicit cursors are
declared and used by the user. more over implicitly cursors are no need to declare oracle
creates and process and closes autometically. the explicit cursor should be declared and
closed by the user.
Implict cursor can be used to handle single record (i.e) the select query used should not
yield more than one row.if u have handle more than one record then Explict cursor should be used.
Posted by: Dinesh
Contact Dinesh
It is not mandatory that when the query retrieves more than one record then explicit cursorshould be used. If the number of records is less than 100 then implicit cursor should be
used.
e.g.set serverout on;
begin
for i in (select * from emp) loopdbms_output.put_line(i.empno);
end loop;
end;
/
Posted by: Sukhamoy
Contact Sukhamoy
Cursor: It is automatically created by oracle for all sql dml statements including the query thatreturns one row.
Explicit cursor: These are created and managed by the user.And used for multi row selectstatement.
Posted by: josu
Contact josu
Implicit cursors are oracle created and used internally by oracle,the only implicit cursor is sql.
Page 1 of 2State the difference between implicit and explicit cursor's.
3/6/2010http://www.coolinterview.com/interview/1 0955/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10955/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10955/8/3/2019 1-PLSQL Interview 3680
12/40
Explicit cursors are user created cursors.
Posted by: Ashish
Contact Ashish
Cursors are used for the purpose of storing the intermediate results when executing a SQL
Query or a block of code...
Implicit Cursors are by default declared by ORacle itself and hence there is no scope of
storing resultset with more than one record where as Explicit Cursors are declared by the
User and hence can define the parameters with measure to store the no of records.
Page 2 of 2State the difference between implicit and explicit cursor's.
3/6/2010http://www.coolinterview.com/interview/1 0955/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10955/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10955/8/3/2019 1-PLSQL Interview 3680
13/40
CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)
AS
l_stmt VARCHAR2(200);
BEGIN
DBMS_OUTPUT.put_line('STARTING ');
l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';
execute IMMEDIATE l_stmt;
DBMS_OUTPUT.put_line('end ');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);
END;
We can create table in procedure as explained in above case. but we can't create or perform
any DDL in functions.
Posted by: Vinod Pandit
Contact Vinod Pandit
the above given answer is correct.
but we can also create or perform any ddl in functions.
I have tested myself
Posted by: Mike
Contact Mike
we can create a table through pl/sql block with dbms_sql package and execute immediate
statement.
CREATE OR REPLACE PROCEDURE PROC_CREATE_NEW_TABLE(STMT VARCHAR2)
IS
Page 1 of 2How we can create a table in PL/SQL block. insert records into it??? is it possible by som...
3/6/2010http://www.coolinterview.com/interview/1 0950/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10950/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10950/8/3/2019 1-PLSQL Interview 3680
14/40
AUTHID CURRENT_USER
BEGIN
EXECUTE IMMEDIATE STMT;
END;
here AUTHID CURRENT_USER is used to create a table under current user privileges.through this procedure we can add our own fields of a table on run time,even it is not
depended on structure of an existing table.
Insertion record into the table, because it is DML operation so we can easily create aprocedure with simple statements or execute immediate statement.
Page 2 of 2How we can create a table in PL/SQL block. insert records into it??? is it possible by som...
3/6/2010http://www.coolinterview.com/interview/1 0950/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10950/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10950/8/3/2019 1-PLSQL Interview 3680
15/40
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched
from a cursor. DatabaseTriggers
Where CURRENT OF clause meanscursor
points to present row of
the cursor
Posted by: sudipta das
Contact sudipta das
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched
from a cursor.
Posted by: Alagappan A M
Contact Alagappan A M
This clause use for update & delete most resent row with out help of ROWID and befour
update lock the particular row in the base table.FOR UPDATE clause is manditory for this
clause.
Posted by: siva kumar
Contact siva kumar
Take an example, Cursor is
Select * from EMP;and in cursor we write
Update Emp set sal = sal + 100;
that means the fetching loops will execute as many times as rows returned by the cursor and
the update will also be done for the same number of times.Now suppose, If we put a where clause in the update statement, then the result would also
not be predictable.
In the third case, we use the WHERE CURRENT OF clause in the where clause, this point out
to the current row returned by the cursor. In that case, Oracle differentiate all the rows on
the basis of RowID. But what happens if someone changes one row in the table.....that
means the rowid would be changed. So we have to manually lock all the rows of that table
by writing the FOR UPDATE/DELETE clause.
So In case of WHERE CURRENT OF clause, we should use the FOR UPDATE/DELETE clause
Page 1 of 3Explain the usage of WHERE CURRENT OF clause in cursors ?
3/6/2010http://www.coolinterview.com/interview/3 693/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3693/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3693/8/3/2019 1-PLSQL Interview 3680
16/40
also. This is known as the Pessimistic/Manual Locking and this the major difference between
the Implicit Cursors and Explicit Cursors.
Posted by: Sachin Nagpal
Contact Sachin Nagpal
UPDATE and DELETE statements can use a WHERE CURRENT OF clause if they reference acursor declared FOR UPDATE. This syntax indicates that the UPDATE or DELETE should
modify the current row identified by the FOR UPDATE cursor. The syntax is:
[UPDATE | DELETE ] ...
WHERE CURRENT OF cursor_name;By using WHERE CURRENT OF, you do not have to repeat
the WHERE clause in the SELECT statement. For example:
DECLARE
CURSOR wip_cur ISSELECT acct_no, enter_date FROM wip
WHERE enter_date < SYSDATE -7FOR UPDATE;
BEGIN
FOR wip_rec IN wip_curLOOP
INSERT INTO acct_log (acct_no, order_date)
VALUES (wip_rec.acct_no, wip_rec.enter_date);
DELETE FROM wip
WHERE CURRENT OF wip_cur;
END LOOP;
END;
Posted by: sallepali nagarjun reddy
Contact sallepali nagarjun reddy
If your program has positioned the cussor on a row,u can update its data by using update
statemnet with where current clause.
Posted by: priya
Contact priya
Where current of is used to delete or update the current row that is being processed in the
cursor loop.
Page 2 of 3Explain the usage of WHERE CURRENT OF clause in cursors ?
3/6/2010http://www.coolinterview.com/interview/3 693/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3693/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3693/8/3/2019 1-PLSQL Interview 3680
17/40
Posted by: karthick VenkataRaman
Contact karthick VenkataRaman
WHERE CURRENT OF CLAUSE is used when referencing the current row from an explicitcursor.
this clause allows to apply updates and deletes to the row currently being addressed,without
the need to explicitly reference ROWID.
We must use the FOR UPDATE clause in the cursor query, such thay the rows are locked on
open.
Page 3 of 3Explain the usage of WHERE CURRENT OF clause in cursors ?
3/6/2010http://www.coolinterview.com/interview/3 693/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3693/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3693/8/3/2019 1-PLSQL Interview 3680
18/40
ROWID - Hexa decimal number each and every row having unique.Used in searching
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are
NEXTVAL,CURRVAL Ofsequence are some exampls
ROWID : It gives the hexadecimal string representing the address of a row.It gives the location in database where row is physically stored.
ROWNUM: It gives a sequence number in which rows are retrieved from the database.
Posted by: jyothsna
Contact jyothsna
ROWID : Every record in a database is uniquely identified by system generated value called
Rowid. It Is a 18 character hexma decimal value. These Rowid's are physically existence.
ROWNUM : It is a pseduocolumn which generates the sequence of numeric values based on
the position ofthe records in the output. These ROWNUM'S logically generated.
NEXTVAL,CURRVAL,SYSDATE,LEVEL ARE PSEDUOCOLUMNS
Posted by: Satyanarayana Reddy velagala
Page 1 of 1Explian rowid,rownum?What are the pseduocolumns we have?
3/6/2010http://www.coolinterview.com/interview/1 0953/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10953/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10953/8/3/2019 1-PLSQL Interview 3680
19/40
Advantage :
In pl/sql if you want perform some actions more than one records you should user these
cursors only. bye using these cursors you process the query records. you can easily move
the records and you can exit from procedure when you required by using cursor attributes.
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.
Disadvantage:
Each time we fetch a row from the cursor, it result a network round trip, where as a normal
select statement query make only one round trip.
Posted by: Praveen Jindal
Contact Praveen Jindal
The guy's answer at the top ofthis page about "Cursors" is probably not wrong but sounds
wrong and it is hard to understand, it sounds like he has tried to type the answer in english
but it is shameful, his english is totally broken, it is bad. You guys at coolinterview.com
should do something about such posting to keep up the readership.
Posted by: good programmer
Contact good programmer
Advantage of cursor1.Basically cursor is a logical place or it is active set.
when a single query returns more than one rows in that case we can use the cursor. we
don't need hit the database several time. Cursoralways points the latest rows.
Disadvantage of cursor1.As such there is no disadvantage
of cursor.
Posted by: sudipta das
Contact sudipta das
Page 1 of 2State the advantage and disadvantage of Cursor?
3/6/2010http://www.coolinterview.com/interview/1 0956/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10956/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10956/8/3/2019 1-PLSQL Interview 3680
20/40
Advantages:
Cursors are somewhat like Pointers of Oracle, Oracle executes a query and assign some
name to that memory location, which is known as Cursor.Cursors are used for storing data temperarorily.
Cursors are used for storing, managing and retrieving data.
Cursors stores in the RAM so the data access and retrieval is fast.
Disadvantage:
No such disadvantage. Only thing is that rather than storing data in an intermediate variable
and fetching it one by one via cursor and then processing it sequentially, we can use
Collections. By using collections, we can pass the bundle of Data at once.
Posted by: Sachin Nagpal
Contact Sachin Nagpal
Cursors adv:
easier to retrieve a batch of records into the cursor and then perform manipulations on them
before displaying the results.
Disadvantage:
The biggest disadvantage of cursors is that they eat up you RAM. If you're retrieving a large
number of records into your cursor inside a procedure on an OLAP database, it will take a
long long time to execute that procedure. The better alternative would be to retrieve directly
from one or more table using selection criteria to eliminate records, and perform
manipulation on each record on the fly.
Posted by: HarshDeep Singh
Contact HarshDeep Singh
cursor is nothing but it's a memory area of executing sql or oracle statements.Advantage:
1. We can retrieve more than one record by one query.
2. It's use our RAM so retrieval is fast.
3. By using Collection we can retrieve the bundle of data in cursor.
Disadvantage:
No such of disadvantage of cursor. When we use cursor one thing is necessary. When I have
select only 50 or 100 rows we should use implicit cursor and when more record then weshould use Explicit cursor.
Posted by: Amit Singh
Page 2 of 2State the advantage and disadvantage of Cursor?
3/6/2010http://www.coolinterview.com/interview/1 0956/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10956/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10956/8/3/2019 1-PLSQL Interview 3680
21/40
InsertUpdateDelete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.If FOR EACH ROW clause is specified, then the trigger for each Row affected by the
statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.
Row level trigger,Statement level trigger,Instead of trigger(created on views)
Posted by: shrinivas singh
Contact shrinivas singh
Baically there only 1 type of trigger which can be fired on the table. .i.e., DML TRIGGER.
There are 14 types of DML TRIGGER
But we can fire only 12 types of triggers, because remaining 2 types of triggers fire on View.
1. Before insert on ROW LEVEL TRIGGER
2. 1. AFTER insert on ROW LEVEL TRIGGER
3. Before insert on STATEMENT LEVEL TRIGGER
4. After insert on STATEMENT LEVEL TRIGGER
5. Before update on ROW LEVEL TRIGGER
6. After update on ROW LEVEL TRIGGER
7. Before update on STATEMENT LEVEL TRIGGER.
8. After update on STATEMENT LEVEL TRIGGER.
9. Before Delete on STATEMENT LEVEL TRIGGER.
10 After Delete on STATEMENT LEVEL TRIGGER.
11. Before Delete on ROW LEVEL TRIGGER.
12 After Delete on ROW LEVEL TRIGGER
Posted by: RISHI RAW AT
Contact RISHI RAWAT
Page 1 of 1How many types of database triggers can be specified on a table ? What are they ?
3/6/2010http://www.coolinterview.com/interview/3 691/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3691/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3691/8/3/2019 1-PLSQL Interview 3680
22/40
Currently, cursor variables are subject to the following restrictions:You cannot declare cursor
variables in a package spec. For example, the following declaration is not allowed:CREATE
PACKAGE emp_stuff AS TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE; emp_cv
EmpCurTyp; -- not allowedEND emp_stuff;You cannot pass cursor variables to a procedure
that is called through a database link.If you pass a host cursor variable to PL/SQL, youcannot fetch from it on the server side unless you also open it there on the same server
call.You cannot use comparison operators to test cursor variables for equality, inequality, or
nullity.You cannot assign nulls to a cursor variable.Database columns cannot store the valuesof cursor variables. There is no equivalent type to use in a CREATE TABLE statement.You
cannot store cursor variables in an associative array, nested table, or varray.Cursors and
cursor variables are not interoperable; that is, you cannot use one where the other is
expected. For example, you cannot reference a cursor variable in a cursor FOR loop
u cannot declare cursor in package specification
not allowed when using db links
cannot use comparison operators
cannot assign NULL
cursor's values cannot be stored in table columns
cannot be used with associative array, nested tables and varray
cannot be use one where the other is expected
cannot reference a cursor variable in cursor FOR LOOP
cannot direclty goto any columns
Posted by: NA
Contact NA
Page 1 of 1What are the Restrictions on Cursor Variables?
3/6/2010http://www.coolinterview.com/interview/1 0946/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10946/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10946/8/3/2019 1-PLSQL Interview 3680
23/40
we cannot commit inside a trigger.
As we all know that when a dml is complete one can issue a commit.
A trigger if created is fired before the dml completes.
so we cannot commit intermediately.
Posted by: kapil sawant
Contact kapil sawant
As workaround, one can use autonomous transactions. Autonomous transactions execute
separate from the current transaction.
Unlike regular triggers, autonomous triggers can contain COMMIT and ROLLBACK statements
Posted by: Jobs
Contact Jobs
Having Commit / Rollback inside a trigger defeats the standard of whole transaction's
commit / rollback al together. Once trigger execution is complete then only a transaction canbe said as complete and then only commit should take place.
If we still want to carry out some action which should be initiated from trigger but should be
commited irrespective of trigger completion / failure we can have AUTONOMUS
TRANSACTION. Inside Automomus transaction block we can have Commit and it will act as
actual commit.
Specific queries a most welcome.
D.
Posted by: Durgesh
Contact Durgesh
We can't perform two action at a time in a trigger i.e trigger action and coomit/rollback/save
point.Otherwise deadlock situation occur as a result we will get a error in the transaction.
Posted by: Swagatika Sarangi
Page 1 of 1Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no ...
3/6/2010http://www.coolinterview.com/interview/1 3419/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/13419/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/13419/8/3/2019 1-PLSQL Interview 3680
24/40
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
Cursorcursor 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 ofDML statement and select statement in pl/sql including queries that returns
single row.cursor have four attributes
1. SQL%ROWCOUNT
2. SQL%ISOPEN3. SQL%NOTFOUND
4. SQL%FOUND
SQL%ROWCOUNT-Basically it returnsnumber.
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 bypresent sql statement.
example of explicit cursor
DECLAREv_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
Page 1 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
25/40
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 orprocedure 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 trigger2.Rowlevel trigger
statement level trigger-statement level trigger means trigger bodyexecute 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 executeonce 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
BEGINTO_CHAR(SYSDATE,'DY')IN('SUN','SAT') OR TO_CHAR((SYSDATE,'HH24:MI')NOT BETWEEN
'08:00' AND '18:00')THENRAISE_APPLICATION_ERROR(-20253,'u may insert employee information at business hrs');
END;
Posted by: Sudipta Das
Contact Sudipta Das
Cursor:
cursor is temporary work area in
pl/sql.
Type of cusor:
1.Implict Cursor
2.Explicit Cursor3.Cursor for loop
4.Cursor With Parametter
Page 2 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
26/40
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
Posted by: 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.
Posted by: Aruna
Page 3 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
27/40
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
Cursorcursor 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 ofDML statement and select statement in pl/sql including queries that returns
single row.cursor have four attributes
1. SQL%ROWCOUNT
2. SQL%ISOPEN3. SQL%NOTFOUND
4. SQL%FOUND
SQL%ROWCOUNT-Basically it returnsnumber.
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 bypresent sql statement.
example of explicit cursor
DECLAREv_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
Page 1 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
28/40
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 orprocedure 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 trigger2.Rowlevel trigger
statement level trigger-statement level trigger means trigger bodyexecute 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 executeonce 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
BEGINTO_CHAR(SYSDATE,'DY')IN('SUN','SAT') OR TO_CHAR((SYSDATE,'HH24:MI')NOT BETWEEN
'08:00' AND '18:00')THENRAISE_APPLICATION_ERROR(-20253,'u may insert employee information at business hrs');
END;
Posted by: Sudipta Das
Contact Sudipta Das
Cursor:
cursor is temporary work area in
pl/sql.
Type of cusor:
1.Implict Cursor
2.Explicit Cursor3.Cursor for loop
4.Cursor With Parametter
Page 2 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
29/40
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
Posted by: 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.
Posted by: Aruna
Page 3 of 3What is trigger,cursor,functions in pl-sql and we need sample programs about it?
3/6/2010http://www.coolinterview.com/interview/1 5106/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15106/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15106/8/3/2019 1-PLSQL Interview 3680
30/40
The table columns are referred as OLD.column_name and NEW.column_name.
For triggersrelated to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only
available.
For triggers related to DELETE only OLD.column_name values only available.
Two tables are: OLD and NEW.
Insert Trigger :
OLD - no value.NEW - inserted value.
UPDATE TRIGGER -OLD- old value.
NEW- new updated value.
DELETE TRIGGER -
OLD - old value.NEW - no value.
Posted by: Sachin Nagpal
Page 1 of 1What are two virtual tables available during database trigger execution ?
3/6/2010http://www.coolinterview.com/interview/3 689/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3689/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3689/8/3/2019 1-PLSQL Interview 3680
31/40
In PL/SQL ,pointer has a datatype REF X where
REF-Reference
X-class of objects
Cursor Variables has a datatype REF-CURSOR
where Cursor Varibales are like pointers which hold the memory location of some item
instead of the item itself.
Posted by: shikha srivastava
Contact shikha srivastava
Ref Cursor is cursor variable. It is a pointer to a result set. It is useful in scenarios when
result set is created in one program and the processing of the same in some other, might bewritten in different language, e.g. firing the select is done in PL/SQL and the processing will
be done in Java.
Posted by: Sukhamoy
Contact Sukhamoy
Its a run time query binding with the cursor variable. Normal cursors are static cursors becaz
they get acquited of query at the compile time.
Posted by: Rup
Contact Rup
Ref cursors are used when we want to use the cursor which is not bound to a specific query.Cursor variables can be tied to many such type of compatible queries.
Posted by: Jyothsna
Contact Jyothsna
Ref cursor is user defined type.Ref cursor allows any type of query for the cursor.Ref cursoris a global declaration of the cursor.Ref cursor is re-usable.
Ref cursor reduces the number of declarations of the cursor in the entire plsql program.Ref
cursor is either static or dynamic.
Page 1 of 2What is ref cursor?
3/6/2010http://www.coolinterview.com/interview/1 1818/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/11818/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/11818/8/3/2019 1-PLSQL Interview 3680
32/40
Posted by: jaali
Contact jaali
Ref cursor is a cursor variable is used to pass the result sets between sub programs.
Ref cursors are 2 types
1.weak Ref cursor and2. Strong Ref cursor
If a ref cursor should not return any value then it is called as weak ref cursor and if a cursorreturns the value then it is strong ref cursor.
weak ref cursors are more flexible because you can associate a weakly typed cursor varibleto any query
Posted by: Aruna
Contact Aruna
Ref cursor is a dynamic cursor with which we can change our query contents at run time.once it is defined thereafter we can declare a cursor variable of that(ref cursor) data type
and write any number of type compatible query against this cursor variable.
Posted by: Ravindra Kumar Ray
Contact Ravindra Kumar Ray
Page 2 of 2What is ref cursor?
3/6/2010http://www.coolinterview.com/interview/1 1818/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/11818/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/11818/8/3/2019 1-PLSQL Interview 3680
33/40
% ROWTYPE is to be used whenever query returns a entire row of a table or view.
TYPE rec RECORD is to be used whenever query returns columns of different
table or views and variables.
E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
);e_rec emp% ROWTYPE
cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.
Page 1 of 1What is difference between % ROWTYPE and TYPE RECORD ?
3/6/2010http://www.coolinterview.com/interview/3 701/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3701/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3701/8/3/2019 1-PLSQL Interview 3680
34/40
You can use DBMS_OUTPUT oracle supplied package or DBMS_DEBUG pasckage.
Posted by: Nasir Ali
Contact Nasir Ali
put a dbms output_putline statment which will dislapay that your procedure is executing
successfully up to which stage.
Posted by: sanjay
Contact sanjay
By using the sql developer tools and in that use breakpoints (the location from which u want todebug and execute line by line at the same time you will notice the current value of the
executed statement below in another windows) and don't forgot to enable the
dbms_output ).
In this way you can do the same things
Posted by: RAJESH KUMAR
Contact RAJESH KUMAR
We can also do line by line execution using tools such as Pl/ SQL Developer, Toad etc
Posted by: Amit Gupta
Contact Amit Gupta
if you want to tune a package then you can use dbms_profiler. if you want to debug use
dbms_debug procedure.
Thanks,
Sudipta
Posted by: Sudipta
Contact Sudipta
Page 1 of 2How to debug the procedure ?
3/6/2010http://www.coolinterview.com/interview/1 5804/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15804/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15804/8/3/2019 1-PLSQL Interview 3680
35/40
ALTER PROCEDURE procedurename
DEBUG;
OR
ALTER PROCEDURE procedurenamePLSQL_DEBUG=TRUE
Posted by: priya
Page 2 of 2How to debug the procedure ?
3/6/2010http://www.coolinterview.com/interview/1 5804/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/15804/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/15804/8/3/2019 1-PLSQL Interview 3680
36/40
By declaring this cursor we can updatethe table emp through z,means wo not need to write
table name for updation,it may be only by "z".
selecting in FOR UPDATE mode locks the result set of rows in update mode, which meansthat row cannot be updated or deleted until a commit or rollback is issued which will release
the row(s).
Posted by: Ash
Contact Ash
You will get an error. Since, the commit/rollback closes the cursor and release the lock if you
use for update of, so trying to fetch out of a closed cursor will raise an error.
Posted by: Nattu
Contact Nattu
The procedure executes successfully.COMMIT will not close the cursor.
declare
b boolean;
cursor c is select * from emp for update;rec c%rowtype;
begin
open c;fetch c into rec;
dbms_output.put_line('NAME is'||rec.ename);
commit;if c%isopen then
dbms_output.put_line('Cursor is not closed '||c%rowcount);
end if;
fetch c into rec;
dbms_output.put_line('NAME is'||rec.ename);end;
O/P
****
NAME isSMITH
Cursor is not closed 1
NAME isALLEN
Page 1 of 3What will the Output for this Coding? Declare Cursor c1 is select * from emp FORUPDA...
3/6/2010http://www.coolinterview.com/interview/1 0945/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10945/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10945/8/3/2019 1-PLSQL Interview 3680
37/40
Posted by: Srikri
Contact Srikri
This coding get sucessful but after completed this query we con't delete or update to the EMP
table because of we used FOR UPDATE clause, they explictly locked the entire row still not
relese.
Posted by: siva kumar
Contact siva kumar
The cursor will execute for first record and then for second record it will raise exception.
Because the ROWS which were locked by FOR UPDATE clause, now been released bycommit.
Posted by: RISHI RAW AT
Contact RISHI RAWAT
The following error will occur as there is a space between IN TO.
ERROR at line 8:
ORA-06550: line 8, column 11:PLS-00103: Encountered the symbol "IN" when expecting one of the following:
. into bulk
Posted by: Chella
Contact Chella
It will ORA:01002 fetch out of sequence error
If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT willreturn the error.
Posted by: kalam
Contact kalam
Page 2 of 3What will the Output for this Coding? Declare Cursor c1 is select * from emp FORUPDA...
3/6/2010http://www.coolinterview.com/interview/1 0945/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10945/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10945/8/3/2019 1-PLSQL Interview 3680
38/40
If the table which we are using in the cursor is empty then procedure will run successfully.
But if table contains rows in it, it will give error as " fetch out of sequence"
Posted by: Trupti Salvi
Page 3 of 3What will the Output for this Coding? Declare Cursor c1 is select * from emp FORUPDA...
3/6/2010http://www.coolinterview.com/interview/1 0945/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/10945/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/10945/8/3/2019 1-PLSQL Interview 3680
39/40
Function is called as part of an expression.
sal := calculate_sal ('a822');
procedure is called as a PL/SQL statement
calculate_bonus ('A822');
Function can be called from SQL query + explicitly as well
e.g 1)select empno,salary,fn_comm(salary)from employee;
2)commision=fn_comm(salary);
Procedure can be called from begin-end clause.
e.g.
Begin(
proc_comm(salary);
)end
Posted by: Hirenkumar
Contact Hirenkumar
Function:Example
Select get_name(Emp_id) from dual.
Procedure:
Example
BeginProcess_employee(EMP_ID);
end;
Posted by: nikhil
Page 1 of 1Explain how procedures and functions are called in a PL/SQL block ?
3/6/2010http://www.coolinterview.com/interview/3 674/PDF created with pdfFactory Pro trial version www.pdffactory.com
http://www.coolinterview.com/interview/3674/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.pdffactory.com/http://www.coolinterview.com/interview/3674/8/3/2019 1-PLSQL Interview 3680
40/40
In the standard package.
Procedures, Functions & Packages ;
It stores in standard_package.
Posted by: Amit Singh
Contact Amit Singh
Page 1 of 1Where the Pre_defined_exceptions are stored ?