Returning array from BuildOp

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Returning array from BuildOp

Post by Grace J. »

Hi All, I have created a BuildOp stage which needs to return an array value. I need to return the value in date_out4 via the output interface outdata1. How can we return an array from BuildOp to datastage. What datatype we need to mention in datastage for date_out4? I tried like below,

APT_String date_out4[8];
oudata1.date_out4[1]=year1;
oudata1.date_out4[2]=month1;
oudata1.date_out4[3]=day1;

But it is giving error as follows... Please help

Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 768.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 45: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 46: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 47: Error: The left operand cannot be assigned to.
3 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource19638-0.C -o /tmp/bosource19638-0_s.o.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What are source lines 40-50, could you post those?
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Post by Grace J. »

outdata1.date_out4[1]=year1;
outdata1.date_out4[2]=month1;
outdata1.date_out4[3]=day1;
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

And how are these variables declared?
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Post by Grace J. »

APT_String date_out4[8];
char year1,month1,day1;
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

And how about "oudata1" or is it "outdata1"?
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Post by Grace J. »

outdata1 only..

outdata1.date_out4[1]=year1;
outdata1.date_out4[2]=month1;
outdata1.date_out4[3]=day1;
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Create a character string (say char tempStr[9] ) and store your result there.

Set the date_out4 from this value.
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Post by Grace J. »

Thank You For Your Reply...I tried as follows...

[b]APT_String date_out4[8],temp[8];
temp[1]=year1;
temp[2]=month1;
temp[3]=day1;
outdata1.date_out4=temp;[/b]

I got the error as follows..

Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 256.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 48: Error: Cannot assign APT_String* to APT_String without "APT_String::operator=(const APT_String&)";.
1 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource26803-0.C -o /tmp/bosource26803-0_s.o.


[b]And I tried as....[/b]

[b]APT_String date_out4[8],temp[8];
temp[1]=year1;
temp[2]=month1;
temp[3]=day1;
outdata1.date_out4[1]=temp[1];
outdata1.date_out4[2]=temp[2];
outdata1.date_out4[3]=temp[3];
writeRecord(0);[/b]

I got the error as...


Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 768.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 48: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 49: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 50: Error: The left operand cannot be assigned to.
3 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource28236-0.C -o /tmp/bosource28236-0_s.o.

Any idea of how to return an array value???
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

What I meant was to use a temporary char variable as below

Code: Select all

char tempStr[9]; // assuming 8 + 1 null

outdata1.date_str4 = tempStr; // direct setting without positional values
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Re: Returning array from BuilOp

Post by Kryt0n »

Grace J. wrote: APT_String date_out4[8];
oudata1.date_out4[1]=year1;
oudata1.date_out4[2]=month1;
oudata1.date_out4[3]=day1;
Never having tried a buildop I'm not sure what an APT_String is but guess a char pointer which then asks what are you trying to return, a set of dates or just one date?

If just one date, return just one string and strip it into day/month/year in DS (pretty much what Sainath has suggested).

If a set of dates, then you need to allocate space to the string for each date or assign date_out4 to the address of year1 etc (date_out4 looks to be a pointer, therefore it needs to look at an address not a value).

From what I can see, option 1 is what you are looking for.

(Of course, this is quite likely down to the fact I haven't done a buildop but why have you declared a date_out4 and then attempt to assign a value to oudata1.date_out4?)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Something I noticed after seeing Kryt0n's response....

You are declaring date_out4 but then attempt to set out_data1.date_out4.

They are two different variables.
Post Reply