Ingres Community Forums Login Register Ingres.com  

Ingres Community Forum


Go Back   Ingres Community Forums > Ingres Forums > OpenROAD Developer's Forum
 

Reply
 
LinkBack Thread Tools Display Modes
Old 2010-03-10   #1 (permalink)
Ingres Community
 
shearerg@onesteel.com's Avatar
 
Join Date: Mar 2007
Location: Newcastle, Australia
Posts: 177
Default Assigning array row to class variable

Hi all,

I have what I expect is a pretty basic question ... but I can't figure it out. I'm just trying to keep my code compact, and thought I'd ask this question before taking a more longhand approach.

Situation is that I have a table field which is an array of user class 'wip_class'. The array populates etc no problem. What I want to do is pass all values from the current row of the table field to a 4GL procedure via a variable of the same class. I know I can do this by assigning each value individually, for example:

wip.coilno = wip_class_tf[field(wip_class_tf).currow].coilno;
wip.mass = wip_class_tf[field(wip_class_tf).currow].mass;
wip.diameter = wip_class_tf[field(wip_class_tf).currow].diameter;
wip.steel = wip_class_tf[field(wip_class_tf).currow].steel;

where 'wip' is of class wip_class and 'wip_class_tf' is a table field array of the same class.

I'm betting there is a simpler way of doing this assignment .. but I haven't been able to find it.

Please forgive my ignorance on this point. I have been referring to the documentation, but without success.

Regards,
Greg Shearer
shearerg@onesteel.com is offline   Reply With Quote
Old 2010-03-10   #2 (permalink)
Ingres Community
 
shearerg@onesteel.com's Avatar
 
Join Date: Mar 2007
Location: Newcastle, Australia
Posts: 177
Default

A bit embarrassed.
I've realised the assignment is as I would have expected.
That is:

wip = wip_class_tf[field(wip_class_tf).currow];

This all test out ok with using debug messages etc.
My problem is with passing 'wip' to the 4GL procedure.
Must be something obvious ... so back to the books.

Greg
shearerg@onesteel.com is offline   Reply With Quote
Old 2010-03-10   #3 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 12
Default

Hi,

does your procedure have a parameter of type wip_class?
I.e. PROCEDURE xxx(p = wip_class, ...)...

It should be possible to pass wip similar to
CALLPROC xxx(p = wip, ...)
or CALLPROC xxx(p = wip.Duplicate, ...) if you want to make sure its values are not altered during the procedure.
Am I missing something?

Regards,

Chris.

Last edited by cbirkl; 2010-03-10 at 10:48 PM.
cbirkl is offline   Reply With Quote
Old 2010-03-11   #4 (permalink)
Ingres Community
 
shearerg@onesteel.com's Avatar
 
Join Date: Mar 2007
Location: Newcastle, Australia
Posts: 177
Default

Chris,

Thanks for your reply ... but I was the one missing something.
I wrote another reply before I left work, but must not have submitted.

Turns out I had been coding with my 'C' glasses on.
I haven't been using OR/Empire for too long, and wasn't using 'callproc' as you suggested.
That is, I'd coded as for a C function call:

DeleteWip(wip)

which simply didn't work. Unusual (or annoying) thing is that my slip wasn't highlighted by the compiler. The procedure appeared to be called, but missing the passed parameter. Anyway, all ok in the end.

My unsent post began 'More embarrassed', and wondered if this whole thread could be deleted. I still think that would be a good idea!

Thanks again,
Greg
shearerg@onesteel.com is offline   Reply With Quote
Old 2010-03-11   #5 (permalink)
Ingres Corp
 
Join Date: Mar 2007
Location: On the OpenROAD
Posts: 828
Default

As Chris mentioned: Your 4GL Procedure only needs a parameter of type wip_class.
Rather than "wip_class_tf[field(wip_class_tf).currow]" you could just use "wip_class_tf[]".
Of course you have to make sure (in both cases) that a row of the tablefield has actually been selected, so field(wip_class_tf).currow should be >0.
Bodo is offline   Reply With Quote

Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


© 2009 Ingres Corporation. All Rights Reserved