Subject | Re: [Firebird-Architect] Re: datatype "enum"? |
---|---|
Author | Martijn Tonies |
Post date | 2005-11-09T11:39:20Z |
> > "enum" actually isn't a datatype at all. It's more of a stringThen what, according to you, are/should be the exact characteristics
> > datatype with a set of possible values.
>
> But that is exactly what I mean.
>
> Think about a field like "gender". It may have the values "male",
> "female" or "unknown". For not storing chars in the database, some
> kind of integer (0,1,2) should be used for storing. There is a
> mapping: 0=unknown, 1=male, 2=female
>
> But a statement like "SELECT gender FROM contact" should give string
> results. In addition a statement like "UPDATE contact SET
> gender='male') should be possible. But internally only integer should
> be stored. The predefined and possible values should be part of the
> schema.
of the "enum" datatype?
I'd rather have "stored functions" available, that would make a
"get string from int value" much easier:
select get_gender_str(gender_code) from contact
create function get_gender_str (gender_code integer)
returns varchar(10)
as
begin
if (gender_code = 0 ) then return 'Unknown'
else if (gender_code = 1) then return 'Male'
etc...
end
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com