Unix Technical Forum

decimal point or comma

This is a discussion on decimal point or comma within the Informix forums, part of the Database Server Software category; --> Hi, I have to create 2 files, one (file-a) must have a decimal point, the other (file-b) a decimal ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 07:45 PM
DeeWee
 
Posts: n/a
Default decimal point or comma

Hi,

I have to create 2 files, one (file-a) must have a decimal point, the other
(file-b) a decimal comma.

Using the SQL Editor I wrote
--------------------------------------------------------
unload to 't:\file-a.txt' DELIMITER ' '
select t_item, t_dsca, t_amount from inv;

unload to 't:\file-b.txt' DELIMITER ' '
select t_item, t_dsca, t_amount from inv;
--------------------------------------------------------

setnet32 is used to set DBMONEY=,

Both files now have a , as decimal sign in t_amount.
How can I temporarily change the , to . ?

TIA,

D. Willems


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 07:46 PM
Dirk Gunsthövel
 
Posts: n/a
Default Re: decimal point or comma

Hi :-)
I dont know if I understand correctly but you can always either
set the registry value or the environment variable DBMONEY
to the desired value between the two runs via a program.
Environment variable is probably better because it changes
the value only for the current shell.

Regards,
Dirk

--
-- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
-- Steinfurter Str. 61 fax: +49 (0)251 1624111
-- D-48149 Muenster http://www.GunCon.de/
-- "The cost of living hasn't affected its popularity."


"DeeWee" <1@2.3> schrieb im Newsbeitrag news:3f656ca9$0$24143$ba620e4c@reader1.news.skynet .be...
> Hi,
>
> I have to create 2 files, one (file-a) must have a decimal point, the other
> (file-b) a decimal comma.
>
> Using the SQL Editor I wrote
> --------------------------------------------------------
> unload to 't:\file-a.txt' DELIMITER ' '
> select t_item, t_dsca, t_amount from inv;
>
> unload to 't:\file-b.txt' DELIMITER ' '
> select t_item, t_dsca, t_amount from inv;
> --------------------------------------------------------
>
> setnet32 is used to set DBMONEY=,
>
> Both files now have a , as decimal sign in t_amount.
> How can I temporarily change the , to . ?
>
> TIA,
>
> D. Willems
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 07:46 PM
DeeWee
 
Posts: n/a
Default Re: decimal point or comma

Thanks for your reaction.
Your suggestion is correct.
I hoped that I could do it in the SQL script i.e. between the two unload's
without leaving the script.

Hoping you have such solution,

D. Willems


"Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
news:bk6u46$pdh$1@news1.transmedia.de...
> Hi :-)
> I dont know if I understand correctly but you can always either
> set the registry value or the environment variable DBMONEY
> to the desired value between the two runs via a program.
> Environment variable is probably better because it changes
> the value only for the current shell.
>
> Regards,
> Dirk
>
> --
> -- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
> -- Steinfurter Str. 61 fax: +49 (0)251 1624111
> -- D-48149 Muenster http://www.GunCon.de/
> -- "The cost of living hasn't affected its popularity."
>
>
> "DeeWee" <1@2.3> schrieb im Newsbeitrag

news:3f656ca9$0$24143$ba620e4c@reader1.news.skynet .be...
> > Hi,
> >
> > I have to create 2 files, one (file-a) must have a decimal point, the

other
> > (file-b) a decimal comma.
> >
> > Using the SQL Editor I wrote
> > --------------------------------------------------------
> > unload to 't:\file-a.txt' DELIMITER ' '
> > select t_item, t_dsca, t_amount from inv;
> >
> > unload to 't:\file-b.txt' DELIMITER ' '
> > select t_item, t_dsca, t_amount from inv;
> > --------------------------------------------------------
> >
> > setnet32 is used to set DBMONEY=,
> >
> > Both files now have a , as decimal sign in t_amount.
> > How can I temporarily change the , to . ?
> >
> > TIA,
> >
> > D. Willems
> >
> >

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 07:50 PM
Dirk Gunsthövel
 
Posts: n/a
Default Re: decimal point or comma

Hi again :-)

I cant see why dividing your dbaccess script into two parts
would be harmfull.

Nevertheless if you really have to do it in one script I would
suggest to set DBMONEY to . and write a Stored
Procedure which changes . to , and use that on the
appropriate columns during the second unload.

Hope that helps.

Regards,
Dirk


> Thanks for your reaction.
> Your suggestion is correct.
> I hoped that I could do it in the SQL script i.e. between the two unload's
> without leaving the script.
>
> Hoping you have such solution,
>
> D. Willems
>
>
> "Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
> news:bk6u46$pdh$1@news1.transmedia.de...
> > Hi :-)
> > I dont know if I understand correctly but you can always either
> > set the registry value or the environment variable DBMONEY
> > to the desired value between the two runs via a program.
> > Environment variable is probably better because it changes
> > the value only for the current shell.
> >
> > Regards,
> > Dirk
> >
> > --
> > -- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
> > -- Steinfurter Str. 61 fax: +49 (0)251 1624111
> > -- D-48149 Muenster http://www.GunCon.de/
> > -- "The cost of living hasn't affected its popularity."
> >
> >
> > "DeeWee" <1@2.3> schrieb im Newsbeitrag

> news:3f656ca9$0$24143$ba620e4c@reader1.news.skynet .be...
> > > Hi,
> > >
> > > I have to create 2 files, one (file-a) must have a decimal point, the

> other
> > > (file-b) a decimal comma.
> > >
> > > Using the SQL Editor I wrote
> > > --------------------------------------------------------
> > > unload to 't:\file-a.txt' DELIMITER ' '
> > > select t_item, t_dsca, t_amount from inv;
> > >
> > > unload to 't:\file-b.txt' DELIMITER ' '
> > > select t_item, t_dsca, t_amount from inv;
> > > --------------------------------------------------------
> > >
> > > setnet32 is used to set DBMONEY=,
> > >
> > > Both files now have a , as decimal sign in t_amount.
> > > How can I temporarily change the , to . ?
> > >
> > > TIA,
> > >
> > > D. Willems
> > >
> > >

> >
> >

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 07:51 PM
DeeWee
 
Posts: n/a
Default Re: decimal point or comma

Thanks for your advices.

Since I've never written a stored procedure I'll split the script.

Thanks

"Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
news:bkekch$h12$1@news1.transmedia.de...
> Hi again :-)
>
> I cant see why dividing your dbaccess script into two parts
> would be harmfull.
>
> Nevertheless if you really have to do it in one script I would
> suggest to set DBMONEY to . and write a Stored
> Procedure which changes . to , and use that on the
> appropriate columns during the second unload.
>
> Hope that helps.
>
> Regards,
> Dirk
>
>
> > Thanks for your reaction.
> > Your suggestion is correct.
> > I hoped that I could do it in the SQL script i.e. between the two

unload's
> > without leaving the script.
> >
> > Hoping you have such solution,
> >
> > D. Willems
> >
> >
> > "Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
> > news:bk6u46$pdh$1@news1.transmedia.de...
> > > Hi :-)
> > > I dont know if I understand correctly but you can always either
> > > set the registry value or the environment variable DBMONEY
> > > to the desired value between the two runs via a program.
> > > Environment variable is probably better because it changes
> > > the value only for the current shell.
> > >
> > > Regards,
> > > Dirk
> > >
> > > --
> > > -- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
> > > -- Steinfurter Str. 61 fax: +49 (0)251 1624111
> > > -- D-48149 Muenster http://www.GunCon.de/
> > > -- "The cost of living hasn't affected its popularity."
> > >
> > >
> > > "DeeWee" <1@2.3> schrieb im Newsbeitrag

> > news:3f656ca9$0$24143$ba620e4c@reader1.news.skynet .be...
> > > > Hi,
> > > >
> > > > I have to create 2 files, one (file-a) must have a decimal point,

the
> > other
> > > > (file-b) a decimal comma.
> > > >
> > > > Using the SQL Editor I wrote
> > > > --------------------------------------------------------
> > > > unload to 't:\file-a.txt' DELIMITER ' '
> > > > select t_item, t_dsca, t_amount from inv;
> > > >
> > > > unload to 't:\file-b.txt' DELIMITER ' '
> > > > select t_item, t_dsca, t_amount from inv;
> > > > --------------------------------------------------------
> > > >
> > > > setnet32 is used to set DBMONEY=,
> > > >
> > > > Both files now have a , as decimal sign in t_amount.
> > > > How can I temporarily change the , to . ?
> > > >
> > > > TIA,
> > > >
> > > > D. Willems
> > > >
> > > >
> > >
> > >

> >
> >

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-19-2008, 07:51 PM
Dirk Gunsthövel
 
Posts: n/a
Default Re: decimal point or comma

Ok. But stored procedures are your friends really :-)
Maybe you want to try the following easy stored proc:

CREATE PROCEDURE dot2comma(theinput CHAR(255)) RETURNING CHAR(255);
DEFINE theoutput CHAR(255);
DEFINE i SMALLINT;
LET i=1;
LET theoutput=theinput;
WHILE i<=LENGTH(theoutput)
IF SUBSTRING(theoutput FROM i FOR 1)="." THEN
LET theoutput=SUBSTRING(theoutput FROM 1 FOR i-1)
||","
||SUBSTRING(theoutput FROM i+1 FOR LENGTH(theoutput)-i);
END IF;
LET i=i+1;
END WHILE;
RETURN theoutput;
END PROCEDURE

The procedure knows nothing about number formats. It just changes all
dots in a string to commas.

Your second unload would then change to:

unload to 't:\file-b.txt' DELIMITER ' '
select t_item, t_dsca, dot2comma(t_amount) from inv;

Regards,
Dirk Gunsthoevel

--
-- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
-- Steinfurter Str. 61 fax: +49 (0)251 1624111
-- D-48149 Muenster http://www.GunCon.de/
-- "The cost of living hasn't affected its popularity."


"DeeWee" <1@2.3> schrieb im Newsbeitrag news:3f6e9ade$0$31715$ba620e4c@reader1.news.skynet .be...
> Thanks for your advices.
>
> Since I've never written a stored procedure I'll split the script.
>
> Thanks
>
> "Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
> news:bkekch$h12$1@news1.transmedia.de...
> > Hi again :-)
> >
> > I cant see why dividing your dbaccess script into two parts
> > would be harmfull.
> >
> > Nevertheless if you really have to do it in one script I would
> > suggest to set DBMONEY to . and write a Stored
> > Procedure which changes . to , and use that on the
> > appropriate columns during the second unload.
> >
> > Hope that helps.
> >
> > Regards,
> > Dirk
> >
> >
> > > Thanks for your reaction.
> > > Your suggestion is correct.
> > > I hoped that I could do it in the SQL script i.e. between the two

> unload's
> > > without leaving the script.
> > >
> > > Hoping you have such solution,
> > >
> > > D. Willems
> > >
> > >
> > > "Dirk Gunsthövel" <dirk@guncon.de> schreef in bericht
> > > news:bk6u46$pdh$1@news1.transmedia.de...
> > > > Hi :-)
> > > > I dont know if I understand correctly but you can always either
> > > > set the registry value or the environment variable DBMONEY
> > > > to the desired value between the two runs via a program.
> > > > Environment variable is probably better because it changes
> > > > the value only for the current shell.
> > > >
> > > > Regards,
> > > > Dirk
> > > >
> > > > --
> > > > -- Dirk Gunsthoevel IT Systemanalyse phone: +49 (0)251 624947
> > > > -- Steinfurter Str. 61 fax: +49 (0)251 1624111
> > > > -- D-48149 Muenster http://www.GunCon.de/
> > > > -- "The cost of living hasn't affected its popularity."
> > > >
> > > >
> > > > "DeeWee" <1@2.3> schrieb im Newsbeitrag
> > > news:3f656ca9$0$24143$ba620e4c@reader1.news.skynet .be...
> > > > > Hi,
> > > > >
> > > > > I have to create 2 files, one (file-a) must have a decimal point,

> the
> > > other
> > > > > (file-b) a decimal comma.
> > > > >
> > > > > Using the SQL Editor I wrote
> > > > > --------------------------------------------------------
> > > > > unload to 't:\file-a.txt' DELIMITER ' '
> > > > > select t_item, t_dsca, t_amount from inv;
> > > > >
> > > > > unload to 't:\file-b.txt' DELIMITER ' '
> > > > > select t_item, t_dsca, t_amount from inv;
> > > > > --------------------------------------------------------
> > > > >
> > > > > setnet32 is used to set DBMONEY=,
> > > > >
> > > > > Both files now have a , as decimal sign in t_amount.
> > > > > How can I temporarily change the , to . ?
> > > > >
> > > > > TIA,
> > > > >
> > > > > D. Willems
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com