How to execute a macro within a macro

Database

How to execute a macro within a macro

Hi Guys,

I got a requirement to execute a macro within a macro.

Below is the example,

Replace Macro Macro1

(

Log INT,

user_id VARCHAR(10)

)

AS

(

INSERT INTO Table1

SELECT

xx,

xx,

version,

:user_id 

FROM volatile_value as t_bulk

WHERE t_bulk.user_id = :p_user_id;

-- i am executing mymacro at this stage. i dont know how to get the version from previous select. So that i can parse the version to the below execute statement. There will be always only one value to the version.

EXECUTE MYMACRO (version, :p_user_id);

Tags (1)
2 REPLIES
Junior Contributor

Re: How to execute a macro within a macro

You can't do this in a macro, you need a Stored Procedure.

Re: How to execute a macro within a macro

Thanks Dieter. Figured that out.

went for a different solution today. 

Join the volatile_value table for "Version" with MYMACRO.

So i wont need version as parameter and wouldnt need a SP as well.

My Macro will only hve user_id as parameter.

hope it works ;-)