Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the Difference between Procedure and Function.Can we
call a Function in a DML?

Answer Posted / ankush

Function always return a value. procedure may or may be not.
IN a select statement function may be called but we should
execute the procedure.

We can call a stored function from dml statement.

Here is simple example


CREATE OR REPLACE FUNCTION TEST_1 RETURN NUMBER IS

BEGIN

RETURN(10);

END;


SELECT TEST_1 FROM DUAL;


update emp

set sal = sal+ sal*test_1();


To be called from an sql statement a function should follow
the following purity rules.
1) When called from a SELECT statement , the function
should not modify database objects.
2) When called from INSERT , UPDATE, DELETE statements ,
the function can not query or modify the tables that was
modified by the statement.
3)When called from SELECT , DELETE, UPDATE, INSERT
Statements , a function should not contain TCL, DDL
commands.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the main difference between sql and pl/sql?

1085


Define union, minus, union all, intersect ?

996


What kind of join is join?

955


how to shut down the server with 'mysqladmin'? : Sql dba

999


What is case function?

1031


Enlist the data types that can be used in pl/sql?

1056


What is the purpose of cursors in pl/sql?

1132


Can we use pl sql in mysql?

1005


Inline the values in PL/SQL, what does it mean.?

1211


How can I tell if sql is running?

1050


how to use 'mysql' to run sql statements? : Sql dba

1040


Why truncate is used in sql?

993


What is a schema sql?

1141


Can you select everything, but 1 or 2 fields, without writer's cramp?

976


What is the maximum number of rows in sql table?

1017