4gl array assignment
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, I have two tables that differ only by one row. I want to do something like: define a1 record like tableOne a2 record like tabletwo let a1[0,9] = a2[1,10] Anybody know how??
steveFarris wrote: > Hi, I have two tables that differ only by one row. I want to do > something like: > > define > a1 record like tableOne > a2 record like tabletwo > > let a1[0,9] = a2[1,10] > > Anybody know how?? Well, you can do whole record assignments: LET a1.* = a2.* Since you've only defined single records, not arrays, your options are rather limited. However, even if you had an array, and you got around the errors due to arrays being 1-based rather than 0-based, you cannot copy slices of arrays like that; you'd have to copy one element at a time. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>
steveFarris wrote: > Hi, I have two tables that differ only by one row. I want to do > something like: > > define > a1 record like tableOne > a2 record like tabletwo > > let a1[0,9] = a2[1,10] > > Anybody know how?? Well, you can do whole record assignments: LET a1.* = a2.* Since you've only defined single records, not arrays, your options are rather limited. However, even if you had an array, and you got around the errors due to arrays being 1-based rather than 0-based, you cannot copy slices of arrays like that; you'd have to copy one element at a time. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>
steveFarris wrote: > > Hi, I have two tables that differ only by one row. I want to do > something like: > > define > a1 record like tableOne > a2 record like tabletwo > > let a1[0,9] = a2[1,10] > > Anybody know how?? Sorry, I'm not quite understanding your pseudocode here. Do you mean that you want to assign the values from the second to tenth members of one record (a2) to the first to ninth members of the other (a1) record? In which case and using 4GL you can do something like: LET a1.* = a2.one THROUGH a1.ten Or at least I think so, no manuals handy so I have likely munged the syntax. It will definitely work if you explicitly assign the elements (LET a1.* = a2.one, a2.two, a1.three etc.). With arrays of course you can only handle element at a time so a bit of attention to your looping structure will take care of getting the right element from one lined up with the other. -- Andrew Pearson: "exactly what the web needs less of".