Total Pageviews

Friday 9 November 2012

Can a macro be called inside a macro?

Can a macro be called inside a macro?

Answer:
The main purpose of run a set of repeated sql queries.   Macro supports only DML queries .
Hence We cant call any-other macro or not even a procedure in a macro.

One trick to have closest functionality of this is to copy all the sql queries from macro2 to macro1 and add parameters if it is necessary as shown below.


replace macro1( val int)
as
(  sel * from employee_table where empid= :val );

replace macro2( dept_no int)
as
(  sel * from employee_table where deptno= :dept_no );

so, to call a macro2 inside a macro1..it is not possible. Hence follow this approach

Replace macro1 (val int, dept_no int)
as
(
sel * from employee_table where empid= :val;
sel * from employee_table where deptno= :dept_no ;
);

No comments:

Post a Comment