08-29-2012 10:12 AM
FILENAME mymail EMAIL "NULL"
select count(*) into h2cnt from test;
select SUBJECT into:sub from test;
select BODY into:cont from test;
select EMAIL_ID into:emilid from test;
This was working and sending and taking only first row
But what i want is to send this to the correspoding user based on that row.
08-29-2012 12:31 PM
A couple of points about using SQL to generate macro variables from data.
1) You can select multiple fields (variables) in one query. Separate the fields with commas and the list the target macro variables after the INTO also separated by commas. Note that the : is required for each target variable.
2) You can select multiple rows (observations) in one query by adding the SEPARATED BY clause after the target macro variable name.
into :sub separated by '|'
, :cont separated by '|'
, emailid separated by '|'
But for you case why not just use the data step to generate the code. For example by using CALL EXECUTE to generating calls to your email macro:
call execute( '%testemail(' || catx(',',emailid,subj,cont) || ')' );