Hi,
I am writing a custom build stage which read a reference input into memory.
I wrote the following in the "Definition Tab"
#include <apt_util/date.h>
APT_Date Lower_Bound [500];
APT_Date Upper_Bound [500];
APT_String Value [500];
int NumLabels=0;
and I wrote the following in the "Pre-Loop" to read all records from the reference stream to memory:
readRecord(1);
while (!inputDone(1))
{
if (NumLabels <= 499)
{
Lower_Bound[NumLabels] = RefRec.Min;
Upper_Bound[NumLabels] = RefRec.Max;
Value[NumLabels] = RefRec.Value;
NumLabels++;
}
readRecord(1);
}
However as the size of the arrays are fixed (e.g. 500), I cannot read a reference stream with all records. Is there any way to due to dynamic array in custom build stage?
Regards,
Derek
Question on Custom Build Stage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Sainath,
Yes, I managed with the malloc for declaring a dynamic array, and realloc when growing the array.
However I hit another problem.
If the Input field is a "null", then if I simply assign this to the variable, Datastage fails to run:
APT_String x;
x=InRec.Field1;
// where InRec is the input and Field1 contains "null"
How can we handle null value for the input?
Regards,
Derek CHU
Yes, I managed with the malloc for declaring a dynamic array, and realloc when growing the array.
However I hit another problem.
If the Input field is a "null", then if I simply assign this to the variable, Datastage fails to run:
APT_String x;
x=InRec.Field1;
// where InRec is the input and Field1 contains "null"
How can we handle null value for the input?
Regards,
Derek CHU