Unload float to integer
Posted in 1999
Topics: Stored Procedures & SPL, Migration, Import/Export & Data Conversion, Third-Party Tools & Monitoring
Hi Group,
I have a decimal field in a table and I want to unload the field to a file
(using the unload command) as an integer. Tried using trunc(), it displays
the result as an integer, but while unloading it puts back the decimal into
it.
The only way I can think about is to create an intermediate temp table which
is not really an option for me.
Any suggestions will be appreciated.
Thanks,
Rana Ray
-----Original Message-----
From: owner-informix-list@iiug.org
[mailto:owner-informix-list@iiug.org]On Behalf Of
Sujit.Pal@BankAmerica.com
Sent: Thursday, June 03, 1999 12:44 PM
To: Talma.Rodrigues@oami.eu.int
Cc: informix-list@iiug.org
Subject: Re: Calculate database space
Talma
There is one in the IIUG (http://www.iiug.org) software repository which
combines oncheck with awk to produce what you want.
HTH
Sujit
Talma.Rodrigues@oami.eu.int on 06/02/99 02:40:18 AM
Please respond to Talma.Rodrigues@oami.eu.int
To: informix-list@iiug.org
cc: (bcc: Sujit Pal)
Subject: Calculate database space
I need a script to calculate the space used for each of my databases.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
rray@painewebber.com wrote: > I have a decimal field in a table and I want to unload the field to > a file (using the unload command) as an integer. Tried using trunc(), > it displays the result as an integer, but while unloading it puts > back the decimal into it. The only way I can think about is to > create an intermediate temp table which is not really an option for > me. If you prefix UNLOAD TO "file" to your SELECT and it produces a different answer, then there's at least a hint of a bug. However, how diabolical have you gotten with your expressions? Is there an INT function in your DBMS you can use (if not, you could write an SP to do the job -- if it is a once only task, this might even be quickest and simplest). Have you tried messing around with the HEX function; it converts its input into an INTEGER? That probably won't work for you, but how much of that section of the manual have you checked through? Would it be an option to edit the output file? Could you arrange to write to a FIFO and have a program sitting reading and massaging the output if there isn't enough space on disk for all the intermediate files. You could try the SQLCMD program (from the IIUG archives) if you're desparate, but I don't warrant that it suppresses the decimal point when formatting a DECIMAL(x,0) for output. Incidentally, I've now got an autoconfiguring version of SQLCMD which could use some testing since its autoconfiguration is bound to be rather sloppy off Linux (RedHat 5.2) and Solaris 2.6. The version I have available today has problems with glibc 2.1.1 (eg RedHat 6.0) -- thanks to someone making stdin, stdout and stderr unusable on the RHS of FILE *fp = stderr; in a global declaration. The fix isn't hard; I just haven't assembled the updated package yet. Let me know if you want to be a guinea pig. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>