I created a view:
create view is3.base_index( bhid, index_1, index_2)
as select bhid,
cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)),
cast(null as decimal(8,4))
from is3.epd
then selected from it:
select * from is3.base_index
where index_1 is not null
order by index_1
expecting the results to be formatted like y.xxxx. What I got is below.
Why is the formatting not what I expected? Is there an easy to force
what I want to see?
140 -32.4 (null)
104162 -31.95 (null)
156973 -31.45 (null)
106005 -31.25 (null)
104002 -30.45 (null)
153400 -30.4 (null)
103786 -28.35 (null)
172478 -28.2 (null)
156044 -28.15 (null)
103294 -27 (null)
103560 -26.75 (null)
105396 -26.5 (null) 6 1080
"Bob Stearns" <rs**********@c harter.net> wrote in message
news:Qv******** *********@fe04. lga... I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
What do you mean that you expected "the results to be formatted like
y.xxxx"? What is "y.xxxx"? Could you please clarify what formatting you
wanted with a few rows of data that respresent what you expected? I can't
tell from your wording whether you are talking about the second column or
the third (or even the first!).
I'm going to guess that you're talking about the third column, although I'm
not quite sure why you'd arbitrarily want to put 0.0000 in the third column
for every row of the result set. If you actually want "0.0000" in the third
column of every row, you could get that with any of the following
expressions in the definition of the third column of the view:
- '0.0000' [this would be a VARCHAR(6), not a number]
- 0.0000 [this would be a DECIMAL(5,4)]
- 0000.0000 [this would be a DECIMAL(8,4)]
- cast (0 as dec(8,4)) [this would be a DECIMAL(8,4)]
If that is not what you mean, please clarify the question, particularly your
expectation for which column should be formatted and how you want the result
to appear.
Rhino
"Bob Stearns" <rs**********@c harter.net> wrote in message
news:Qv******** *********@fe04. lga... I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
CAST statements in view definitions have no effect. The rows are formatted
based on the variable types used in the SELECT statement (ie, those of the
underlying table's columns or those implied as a result of caluclations.)
What you really want to do is use them in your select statement instead,
like this:
select bhid, cast(index_1 as decimal(8,4)), cast(index_2 as decimal(8,4))
from is3.base_index
where index_1 is not null
order by index_1
If you want NULL values to show up as zeroes (instead of "(null)" or "-"),
then you should consider using the COALESCE function, like this:
select bhid, cast(index_1 as decimal(8,4)), cast(coalesce(i ndex_2,0) as
decimal(8,4)) from is3.base_index
where index_1 is not null
order by index_1
--
Matt Emmerton
Rhino wrote: "Bob Stearns" <rs**********@c harter.net> wrote in message news:Qv******** *********@fe04. lga...
I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
What do you mean that you expected "the results to be formatted like y.xxxx"? What is "y.xxxx"? Could you please clarify what formatting you wanted with a few rows of data that respresent what you expected? I can't tell from your wording whether you are talking about the second column or the third (or even the first!).
I'm going to guess that you're talking about the third column, although I'm not quite sure why you'd arbitrarily want to put 0.0000 in the third column for every row of the result set. If you actually want "0.0000" in the third column of every row, you could get that with any of the following expressions in the definition of the third column of the view: - '0.0000' [this would be a VARCHAR(6), not a number] - 0.0000 [this would be a DECIMAL(5,4)] - 0000.0000 [this would be a DECIMAL(8,4)] - cast (0 as dec(8,4)) [this would be a DECIMAL(8,4)]
If that is not what you mean, please clarify the question, particularly your expectation for which column should be formatted and how you want the result to appear.
Rhino
I mean, of course the second column. What I was expecting was:
140 -32.4000 (null)
104162 -31.9500 (null)
156973 -31.4500 (null)
106005 -31.2500 (null)
104002 -30.4500 (null)
153400 -30.4000 (null)
103786 -28.3500 (null)
172478 -28.2000 (null)
156044 -28.1500 (null)
103294 -27.0000 (null)
103560 -26.7500 (null)
105396 -26.5000 (null)
Matt Emmerton wrote: "Bob Stearns" <rs**********@c harter.net> wrote in message news:Qv******** *********@fe04. lga...
I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
CAST statements in view definitions have no effect. The rows are formatted based on the variable types used in the SELECT statement (ie, those of the underlying table's columns or those implied as a result of caluclations.)
What you really want to do is use them in your select statement instead, like this:
select bhid, cast(index_1 as decimal(8,4)), cast(index_2 as decimal(8,4)) from is3.base_index where index_1 is not null order by index_1
If you want NULL values to show up as zeroes (instead of "(null)" or "-"), then you should consider using the COALESCE function, like this:
select bhid, cast(index_1 as decimal(8,4)), cast(coalesce(i ndex_2,0) as decimal(8,4)) from is3.base_index where index_1 is not null order by index_1
-- Matt Emmerton
Thank you. I didn't realize the CASTs in the VIEW were ignored. Perhaps
they should be diagnosed as warnings at least.
"Bob Stearns" <rs**********@c harter.net> wrote in message
news:nT******** *******@fe06.lg a... Rhino wrote:
"Bob Stearns" <rs**********@c harter.net> wrote in message news:Qv******** *********@fe04. lga...
I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
What do you mean that you expected "the results to be formatted like y.xxxx"? What is "y.xxxx"? Could you please clarify what formatting you wanted with a few rows of data that respresent what you expected? I
can't tell from your wording whether you are talking about the second column
or the third (or even the first!).
I'm going to guess that you're talking about the third column, although
I'm not quite sure why you'd arbitrarily want to put 0.0000 in the third
column for every row of the result set. If you actually want "0.0000" in the
third column of every row, you could get that with any of the following expressions in the definition of the third column of the view: - '0.0000' [this would be a VARCHAR(6), not a number] - 0.0000 [this would be a DECIMAL(5,4)] - 0000.0000 [this would be a DECIMAL(8,4)] - cast (0 as dec(8,4)) [this would be a DECIMAL(8,4)]
If that is not what you mean, please clarify the question, particularly
your expectation for which column should be formatted and how you want the
result to appear.
Rhino
I mean, of course the second column.
[snip]
Then perhaps you should have made that clear in your original question. It
certainly wasn't obvious to *me* that you meant the second column.
Rhino
"Bob Stearns" <rs**********@c harter.net> wrote in message
news:nZ******** *******@fe06.lg a... Matt Emmerton wrote:
"Bob Stearns" <rs**********@c harter.net> wrote in message news:Qv******** *********@fe04. lga...
I created a view:
create view is3.base_index( bhid, index_1, index_2) as select bhid, cast(0+1.5*birt h_epd+2.5*weani ng_epd as decimal(8,4)), cast(null as decimal(8,4)) from is3.epd
then selected from it:
select * from is3.base_index where index_1 is not null order by index_1
expecting the results to be formatted like y.xxxx. What I got is below. Why is the formatting not what I expected? Is there an easy to force what I want to see?
140 -32.4 (null) 104162 -31.95 (null) 156973 -31.45 (null) 106005 -31.25 (null) 104002 -30.45 (null) 153400 -30.4 (null) 103786 -28.35 (null) 172478 -28.2 (null) 156044 -28.15 (null) 103294 -27 (null) 103560 -26.75 (null) 105396 -26.5 (null)
CAST statements in view definitions have no effect. The rows are
formatted based on the variable types used in the SELECT statement (ie, those of
the underlying table's columns or those implied as a result of
caluclations.) What you really want to do is use them in your select statement instead, like this:
select bhid, cast(index_1 as decimal(8,4)), cast(index_2 as
decimal(8,4)) from is3.base_index where index_1 is not null order by index_1
If you want NULL values to show up as zeroes (instead of "(null)" or
"-"), then you should consider using the COALESCE function, like this:
select bhid, cast(index_1 as decimal(8,4)), cast(coalesce(i ndex_2,0) as decimal(8,4)) from is3.base_index where index_1 is not null order by index_1
-- Matt Emmerton Thank you. I didn't realize the CASTs in the VIEW were ignored. Perhaps they should be diagnosed as warnings at least.
Actually, I was wrong. CASTs defined in a VIEW are valid and are NOT
ignored, so the original query was fine.
However, note that a CAST merely changes DB2's internal handling of the
column type, and does not neccessarily change how the output of the data is
formatted. Formatting of the output data is the responsiblity of the client
application. The DB2 CLP is a database client and has it's own ways of
formatting the output of queries.
--
Matt Emmerton This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Uwe Mayer |
last post by:
Hi,
I have a subclassed PyQt class:
class Node(object):
def move(self, x,y): pass
class CRhomb(QCanvasPolygon, Node): pass
$ python
|
by: AFN |
last post by:
I am running the code below to generate XML from a data table. But some
fields in the data table are Null for every record. Suppose field5 has a
null database value. I would expect to see:
<field5></field5> or <field5 />
but instead it doesn't even show the field at all for those records where
field5 is Null! Instead it just shows:
<field4>Whatever</field4>
|
by: LP |
last post by:
I am using (trying to) CR version XI, cascading parameters feature works it
asks user to enter params. But if page is resubmitted. It prompts for params
again. I did set ReuseParameterValuesOnRefresh="True" in a viewer, but it
still doesn't work. Did anyone run into this problem. What's the solution?
Please help.
Thank you
|
by: Martin P. Hellwig |
last post by:
Hi all,
I was doing some popen2 tests so that I'm more comfortable using it.
I wrote a little python script to help me test that (testia.py):
---------------------------------
someline = raw_input("something:")
if someline == 'test':
print("yup")
|
by: aldonnelley |
last post by:
Hi all.
Just having a weird problem with tkinter. I'm trying to make a gui that
shows results from an image search, with a "forward" and "back" button
so the user can compare results from different pages. All that's
working fine...
The problem I'm having is that the images don't show onscreen the first
time the "first page" of results shows up. When I click the "search
again" button, and have more than the original results page to...
| |
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= |
last post by:
Hello,
I have build a website with approximately 30 html-pages.
When I search this website in Google, I see the index.html or home.html on
this website, but also other html-pages on this website.
When I click in Google on one of these pages (not index.html or home.html),
I am only linked to that one html-page and not to the website itself.
Does anyone know how to fix this. Is there for example a metatag?
Thanks
|
by: None |
last post by:
Hi All
These code are part of Prototype. There are something that I don't
understand, would you please explain it for me?
.......
toJSON: function(object) {
var type = typeof object;
switch (type) {
case 'undefined':
|
by: Stef Mientki |
last post by:
Terry Reedy wrote:
sorry, don't know how this happened, as I always copy/paste ?
AFAIK locals() == sys._getframe(0).f_locals
AFAIK, again one level up
weird, I use it in 2.5 and if I remember well it already worked in 2.4.
but exchanging the function with the statement yields exactly the same
results
Yes ;-)
done.
|
by: OldBirdman |
last post by:
This code is in a Module called from an _Click event for my form named fAAA. Variables beginning ix... are Global Long, declared elsewhere.
Public Sub QuickShow()
On Error GoTo QuickShow_Error
'Display Quick Dropdown ListBox
If ixQuickLevel = 0 Then Exit Sub
Forms!fAAA.cboQuick = Forms!fAAA.cboQuick.DefaultValue
Forms!fAAA.cboQuick.ListRows = ixQuickCount
Forms!fAAA.cboQuick.SetFocus
Forms!fAAA.cboQuick.Dropdown
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |