4GL REPLACE FUNCTIOn
Posted in 2006
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I have an exsisting 4GL program which does a simple data dump, but I would like to manipulate one feild in the dump by using the replace function as in SQL. But this doesn't work within 4GL. Does any one have a workaround? replace(idno, substr(idno,1,5), 'XXXXX') Thanks
Hendrick wrote: > I have an exsisting 4GL program which does a simple data dump, but I > would like to manipulate one feild in the dump by using the replace > function as in SQL. But this doesn't work within 4GL. Does any one have > a workaround? > > replace(idno, substr(idno,1,5), 'XXXXX') LET idno[1,5] = 'XXXXX' It's harder when you have to deal with a variable offset - such as trying to replace 'feild' with 'field'. In SPL, you're stuck with constant subscripts. IIRC, in I4GL, you are not (one reason why the SPL limitation was so frustrating). But the search part is hard(er). Poke around the IIUG Software Archive; there are most likely some functions in there to do the job.
Hendrick wrote:
> I have an exsisting 4GL program which does a simple data dump, but I
> would like to manipulate one feild in the dump by using the replace
> function as in SQL. But this doesn't work within 4GL. Does any one have
> a workaround?
>
> replace(idno, substr(idno,1,5), 'XXXXX')
>
>
> Thanks
you can do two things:
1) if you need to use the unload command then this can be achieved
with:
--
select replace(idno, substr(idno,1,5), 'XXXXX') from idtable into temp
t1;
unload to idtable.unl select * from t1
--
not good if you have a large amount of data
2) use fetch/foreach into "variable", manipulate it using "let variable
= "XXXXX", variable[6,length of variable]" then output to report
hope this helps, cheers!
"Jonathan Leffler" <jonathan.leffler@gmail.com> wrote in message news:1151549904.233452.76870@j72g2000cwa.googlegroups.com... > Hendrick wrote: >> I have an exsisting 4GL program which does a simple data dump, but I >> would like to manipulate one feild in the dump by using the replace >> function as in SQL. But this doesn't work within 4GL. Does any one have >> a workaround? >> >> replace(idno, substr(idno,1,5), 'XXXXX') > > LET idno[1,5] = 'XXXXX' > > It's harder when you have to deal with a variable offset - such as > trying to replace 'feild' with 'field'. In SPL, you're stuck with > constant subscripts.
If you are on V9/10 then you can install the regexp datablade Cheers Paul "Hendrick" <hendrickq@hotmail.com> wrote in message news:1151531900.970313.109390@y41g2000cwy.googlegroups.com... >I have an exsisting 4GL program which does a simple data dump, but I > would like to manipulate one feild in the dump by using the replace > function as in SQL. But this doesn't work within 4GL. Does any one have > a workaround? > > replace(idno, substr(idno,1,5), 'XXXXX') > > > Thanks >