Re: SPL question - how to clip text???
Posted in 1996
From Cathy Kipp:
}In article <4v089u$l80@cssun.mathcs.emory.edu>,
}Alan Goodman <alan@dssmktg.com> wrote:
}>In version 5.xx online (sorry, but I'm not sure exactly what version), how
}>does one go about implementing a function like the 4GL "clipped" function?
}>
}>What we are doing is converting data from an old table with fixed length
}>fields to a new table with varchar fields. Unfortunately, when you read
}>a fixed length field into a varchar in an SPL, the varchar is padded with
}>trailing spaces to the length of the fixed length field. When this
}>varchar is inserted into the varchar field in the new table, the trailing
}>spaces are maintained.
}>
}>We need some way to clip the trailing spaces prior to record insert.
}>
}
}It kind of depends on how you are unloading/loading the table.
Not unloading the table at all. Reading records from one table and
mapping the fields to different fields in another table.
}It's not clear to me if you have a specific reason for using SPL.
Using SPL so we don't have to compile 4GL on every customer's system in
order to do the data conversion. If something goes wrong, we can edit the
spl creation scripts, and run them again, without having to modify 4GL code
and recompile. The recompilation is a problem for those customers with
run-time informix.
}A couple of ways I have done it:
}
}1) Use the sql unload statement. Run this output file through your
} favorite UNIX utility (awk, sed, perl) replacing any number of
} occurrences of " |" with "|".
That works fine, but we are converting .9 GB of data and I don't
want to unload the data for each table if I don't have too.
}
}2) Use the 4gl (or Ace) reporting utility to create an appropriate
} unload file. You can use the clipped function when doing your
} unload this way.
}
}Then use dbload or load to insert the data.
Again, I don't want to unload the data unless I absolutely have to.
}Regards,
}
}Cathy
}------------------------------------------------------------------------
}Cathy Kipp E-mail: ckipp@verinet.com
}Principal Consultant Fort Collins, Colorado, USA
}Database Strategies, Inc.
}------------------------------------------------------------------------
Thanks,
Alan
------------------------------------------------------------------------------
Alan Goodman | Data Systems Support
Senior Systems Analyst | A Client Technologies Company
internet : alan@dssmktg.com | 1228 Shelly Ct.
Voice 714-771-0454 Fax 714-771-3028 | Orange, CA 92868 USA
------------------------------------------------------------------------------