Unix Technical Forum

Datatype for creating a range value in db2

This is a discussion on Datatype for creating a range value in db2 within the DB2 forums, part of the Database Server Software category; --> Hi I would like to have an attribute that would store an integer or float range (say 6 to ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:52 AM
Mahesh S
 
Posts: n/a
Default Datatype for creating a range value in db2

Hi

I would like to have an attribute that would store an integer or float
range (say 6 to 10). Is it possible to have both the lower and upper
limit specified in a single field?

Thanks
Mahesh

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:52 AM
Serge Rielau
 
Posts: n/a
Default Re: Datatype for creating a range value in db2

Mahesh S wrote:
> I would like to have an attribute that would store an integer or float
> range (say 6 to 10). Is it possible to have both the lower and upper
> limit specified in a single field?

Not sure what you mean.
Attributes are elements of structured types. Are you talking about a
structured type?
CREATE TYPE address AS (no INTEGER, street VARCHAR(30))
and you you want to constrain the attribute?
You can't do this as part of CREATE TYPE, but you can overload the
"mutator" and "constructor" to constrain what can be set.

Or are you talking about a column rather than attribute?
CREATE TABLE T(c1 float check (c1 between 6 and 10))

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:53 AM
Mahesh S
 
Posts: n/a
Default Re: Datatype for creating a range value in db2

Hi Serge

Well, let me clarify my question. What I would like to have is a
single field that stores a range value instead of a single number. For
instance, normally, you would store in an int field, say value 5. What
I want to do instead is store the value [6, 10] inside a field which
represents a range rather than a single value. Is that making any
sense? Are there any structured types available that would let me
store a range instead of a single value. I hope you are familiar with
this math notation [6,10] which implies all values between and
including 6 and 10.

Thanks
Mahesh

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:53 AM
Serge Rielau
 
Posts: n/a
Default Re: Datatype for creating a range value in db2

Mahesh S wrote:
> Hi Serge
>
> Well, let me clarify my question. What I would like to have is a
> single field that stores a range value instead of a single number. For
> instance, normally, you would store in an int field, say value 5. What
> I want to do instead is store the value [6, 10] inside a field which
> represents a range rather than a single value. Is that making any
> sense? Are there any structured types available that would let me
> store a range instead of a single value. I hope you are familiar with
> this math notation [6,10] which implies all values between and
> including 6 and 10.

You could create your own structured type "range"
with, say, 4 attributes: lower bound, upper bound, inclusive_low,
inclusive_high.
OO is pretty haavy stuff and therefore not exactly popular outside of
academia.
I'm wondering why you would go through these lengths instead of simply
storing the base information in the table.
Cheers
Serge



--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 07:53 AM
Mahesh S
 
Posts: n/a
Default Re: Datatype for creating a range value in db2

yes, that does sound complicated.. will opt for the easy way out..
thanks..

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 06:01 AM.


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