Text File from Informix Database
Posted in 1999
Topics: Migration, Import/Export & Data Conversion
S'o Paulo - Brazil - April 26 , 1999. Dear Friends, Can you help me ?????? How can I get a text file ( unload or output) from a Informix Database with the blank spaces that belong to the end of fields. My problem is I have a Cobol program that will read this file, so I need fixed length fields. For Example: In a text file created by an Informix Database, the fields appear : 1234|Adam Smith|single|04/01/1961 1235|Joan Norton Maguire|married|08/10/1970 I need: 1234|Adam Smith |single |04/01/1961 1235|Joan Norton Maguire |married |08/10/1970 The Informix version is 5.10. The command used is "unload". If you have some suggestion I would aprecciate ............. Thank you very much Sincerely, Paulo Rog'rio
Hi Paulo, I find the ACE Report tool very handy for jobs like this. If your system has it, then it will be part of you isql tools. Its basically a quick report writer that allows you to use SQL and some 4GL logic to produce a file. Very handy and powerful. Alex Paulo Rogerio wrote in message <7g549i$jis$1@news.xmission.com>... > >S'o Paulo - Brazil - April 26 , 1999. > >Dear Friends, > >Can you help me ?????? > >How can I get a text file ( unload or output) from a Informix Database with >the blank spaces that belong to the end of fields. >My problem is I have a Cobol program that will read this file, so I need >fixed length fields. > >For Example: > >In a text file created by an Informix Database, the fields appear : > >1234|Adam Smith|single|04/01/1961 >1235|Joan Norton Maguire|married|08/10/1970 > >I need: > >1234|Adam Smith |single |04/01/1961 >1235|Joan Norton Maguire |married |08/10/1970 > >The Informix version is 5.10. The command used is "unload". > >If you have some suggestion I would aprecciate ............. > > >Thank you very much > >Sincerely, > > >Paulo Rog'rio >
Some possibilities:
A. If you have either Informix-4GL or ESQL/C, you can write a program that does
it. In these programs people usually have the opposite problem - they want to
*avoid* including the extra spaces when they select data. This is because by
default the fixed length field, blank padded right is returned for all columns
defined as char.
For example in 4GL:
--------------------------------------------------------------------------
database yourdb
main
define rowx record like tablex.*
declare c_1 cursor for
select col1, col2, col3, col4
from tablex
foreach c1_ into rowx.col1, rowx.col2, rowx.col3, rowx.col4
display rowx.col1, "|", rowx.col2, "|", rowx.col3, "|", rowx.col4
end foreach
end main
-------------------------------------------------------------------------
B. Yes, you can feed your unloaded data file to an awk program, for example:
-------------------------------------------------
awk -F'|' '{
printf("%s|%30s|%10s|%s", $1, $2, $3, $4)
}' unloadfile
-------------------------------------------------
Paulo Rogerio wrote:
> São Paulo - Brazil - April 26 , 1999.
>
> Dear Friends,
>
> Can you help me ??????
>
> How can I get a text file ( unload or output) from a Informix Database with
> the blank spaces that belong to the end of fields.
> My problem is I have a Cobol program that will read this file, so I need
> fixed length fields.
>
> For Example:
>
> In a text file created by an Informix Database, the fields appear :
>
> 1234|Adam Smith|single|04/01/1961
> 1235|Joan Norton Maguire|married|08/10/1970
>
> I need:
>
> 1234|Adam Smith |single |04/01/1961
> 1235|Joan Norton Maguire |married |08/10/1970
>
> The Informix version is 5.10. The command used is "unload".
>
> If you have some suggestion I would aprecciate .............
>
> Thank you very much
>
> Sincerely,
>
> Paulo Rogério
Hi, Try WinSQL Professional at http://www.imranweb.com/freesoft. You can do exactly what you want to do. Thanks, Imran. Paulo Rogerio wrote: > São Paulo - Brazil - April 26 , 1999. > > Dear Friends, > > Can you help me ?????? > > How can I get a text file ( unload or output) from a Informix Database with > the blank spaces that belong to the end of fields. > My problem is I have a Cobol program that will read this file, so I need > fixed length fields. > > For Example: > > In a text file created by an Informix Database, the fields appear : > > 1234|Adam Smith|single|04/01/1961 > 1235|Joan Norton Maguire|married|08/10/1970 > > I need: > > 1234|Adam Smith |single |04/01/1961 > 1235|Joan Norton Maguire |married |08/10/1970 > > The Informix version is 5.10. The command used is "unload". > > If you have some suggestion I would aprecciate ............. > > Thank you very much > > Sincerely, > > Paulo Rogério -- =========================================== Imran Hussain MCP, MCSD imranh@imranweb.com FOR FREE Software http://www.imranweb.com/freesoft ===========================================
Paulo Rogerio wrote: >Sco Paulo - Brazil - April 26 , 1999. > >Dear Friends, > >Can you help me ?????? > >How can I get a text file ( unload or output) from a Informix Database with >the blank spaces that belong to the end of fields. >My problem is I have a Cobol program that will read this file, so I need >fixed length fields. > >For Example: > >In a text file created by an Informix Database, the fields appear : > >1234|Adam Smith|single|04/01/1961 >1235|Joan Norton Maguire|married|08/10/1970 > >I need: > >1234|Adam Smith |single |04/01/1961 >1235|Joan Norton Maguire |married |08/10/1970 > >The Informix version is 5.10. The command used is "unload". > >If you have some suggestion I would aprecciate ............. > > >Thank you very much > >Sincerely, > > >Paulo Rogirio > If you have ISQL, take a look at generating your unload files using ace reports. It has been a while, but I seem to remember that if you don't use the clipped option after column names you may get trailing blanks. You will have to program to insert the "|" delimiter. Perhaps I4GL works the same way. Randall Young ryoung@bix.com