What is macro. What is the difference between macro and procedure.
A macro is the set of sql statements which can be run as a single statement.Macro Procedure
Macro returns set of data/rows to the user. It does not return data/rows to the user.
It is allows only input values. It provides Input/Output parameter.
It is stored in DBC Perm space. It is stored in DATABASE/USER Perm space.
To create a macro:
CREATE MACRO macro_name AS(SELECT eid, ename FROM emp WHERE deptno=20;);
To execute a macro:
EXEC macro_name;
To create a parametrized macro:
CREATE MACRO macro_name( in_param DATATYPE)
(SELECT eid, ename FROM emp WHERE deptno= :in_param;);
To execute a macro:
EXEC <macro_name> [parameter value list];