- Procedure can performs one or more tasks where as function performs a specific task.
- Procedure may or may not return value where as function should return one value.
- We can call functions in select statement where as procedure we cant.
- We can call function within procedure but we can not call procedure within function.
- A FUNCTION must be part of an executable statement, as it cannot be executed independently, whereas procedure represents an independent executable statement.
- Function can be called from SQL statement where as procedure can't be called from the SQL statement.
- Function are normally used for computation where as procedure are normally used for executing business logic.
- Stored procedure supports deferred name resolution where as function wont support.
- Stored procedure returns always integer value by default zero. where as function returns type could be scalar or table or table value.
- Stored procedure is pre-compiled execution plan where as function are not.
Monday, 6 March 2017
What is the difference between function and procedure in PL/SQL?
Monday, 16 January 2017
In a PL/SQL procedure, how do i pass a table name as a parameter?
CREATE OR REPLACE PROCEDURE KAU (T_NAME VARCHAR2)
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE '||T_NAME||'(A NUMBER,B VARCHAR2(20))';-----------------------------create table
--EXECUTE IMMEDIATE 'INSERT INTO '|| t_name ||' VALUES (1,"amol")';---------insert into table
--EXECUTE IMMEDIATE 'DROP TABLE '||T_NAME||' ';-------drop table
END;
/
--------to execute
begin
kau('emp');
end;
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE '||T_NAME||'(A NUMBER,B VARCHAR2(20))';-----------------------------create table
--EXECUTE IMMEDIATE 'INSERT INTO '|| t_name ||' VALUES (1,"amol")';---------insert into table
--EXECUTE IMMEDIATE 'DROP TABLE '||T_NAME||' ';-------drop table
END;
/
--------to execute
begin
kau('emp');
end;
Subscribe to:
Posts (Atom)