Re: dyanamic variable in embedded SQL in for loop in C
Date: Thu, 08 Jul 1999 16:47:19 GMT
Message-ID: <7m2kmi$gfk$1_at_nnrp1.deja.com>
Hi James,
My Pro/C work only used input file loops
and Insert statements.....
but can you not also write CURSOR constructs
inside Pro/C? Seems to me that this is the
approach you want...
Thus, your loop would become something like this (since I don't know the exact Pro/C syntax, forgive me in advance...)
....declare the cursor....
EXEC SQL
Cursor my12months is
select count(*) into :a11
from sorted
where rid=:rid AND
ddate between last_day(add_months(SysDate, -12)) + 1 AND
last_day(add_months(SysDate, -11)) + 1 ORDER BY DDATE; Then your loop becomes a series of FETCHES into the array[i] variable...
int max, i;
max=0;
EXEC SQL Open my12months;
for (i=13, i<=1, i--)
{EXEC SQL
FETCH my12months INTO :CVariableForDDate, :CVariableForData;
...m = ...figure out what month it is in DDate...;
a[ m ] = CVariableForData;
}
EXEC SQL Close my12months;
...Of course you could get slicker and add exception handling...if no records found, etc. etc....
Good Luck
Robert Proffitt
Beckman Coulter
> James Thomson
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Thu Jul 08 1999 - 18:47:19 CEST