IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding char(decimal)


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Fri Oct 26, 2007 5:28 pm
Reply with quote

Hi,

Can you please let me know how below expression will work

CHAR(SUM(INTEGER(DECIMAL((0.03*0.03),17,6)/DECIMAL((0.03*0.03),17,6)-0.001) )))

When I tried it is giving junk values...
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Oct 26, 2007 5:33 pm
Reply with quote

What are you trying to accomplish?
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Fri Oct 26, 2007 7:42 pm
Reply with quote

I need to fix above problem, which happend in live.

I treid with other values in place of 0.03 (with 126.25), where it is giving correct result

But when I tried with 0.03, it is giving junk values. Hence need to analyze on why it's giving junk values for 0.03
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 26, 2007 8:41 pm
Reply with quote

what exactly are these junk values?
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Sat Oct 27, 2007 1:30 pm
Reply with quote

I am really sorry to say, do you really need what junk values it is giving to explain above one
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Oct 27, 2007 4:31 pm
Reply with quote

I am ready to say that anyone who describes output from anything as 'JUNK' is in a really sorry situation. It appears that you don't know very much.

The sql contains no columns or host-variables. Why are you using all these column functions? integer, decimal etc. when you cast as integer, you lose your decimal positions (i.e. values between .999999999999999 and .0000000000001.

and the reason that I wanted to know what the 'junk' was, is that I understand what the computer does when it executes, thus I could have worked backwards to see why your results are different when you use a value greater than 1 (as apposed to less than 1).

but, you seem to know it all (instead of simply answering my question, you give me a BS response). hope someone else has patience and will help you.

have a good weekend.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Oct 27, 2007 5:09 pm
Reply with quote

wow...

integer( (x*x) / ( (x*x) - 0.001)
wasting bandwitdh for a computation that will always yield a 0 or a 1
given the appropriate number of decimal digits

Quote:
I am really sorry to say, do you really need what junk values it is giving to explain above one


I agree that refusing to tell what the junk is he is safeguarding
confidential info

I would had done the same
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Oct 27, 2007 5:46 pm
Reply with quote

what in the world could be confidential about this garbage or the 'output' of this SQL execution? It looks like to me that the sql is summing a bunch of integers.

Code:

CHAR(SUM(INTEGER(DECIMAL((0.03*0.03),17,6)/DECIMAL((0.03*0.03),17,6)-0.001) )))


Code:

CHAR(
    SUM(
        INTEGER(
            DECIMAL(
                 (0.03*0.03),17,6
            )
          /
            DECIMAL(
                (0.03*0.03),17,6
            )
          -0.001
        )
    )
)
)


there are no host variables, there are no columns. The is nothing except literals and column functions.

There is no such thing as 'junk' as output. It may not be what 'you want', but the computer only does what you tell it to do by means of your code (be it JCL, cobol programs, SQL). The computer is not a person; it can not determine what you 'wanted' - only what you told it todo. So, since computers are predictable, you can trace a result backwards thru the code that was executed and determine the original input.

So, this silliness about confidential info does not apply here. And even if it did, the OP could have stated so instead of providing a childish response.
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Mon Oct 29, 2007 4:44 pm
Reply with quote

Thanks and Bye to this group
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Oct 29, 2007 4:57 pm
Reply with quote

Quote:
Thanks and Bye to this group


Thanks for what ??
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top