Factoring Enum Out of Code

This is a discussion on Factoring Enum Out of Code within the MySQL Database forums, part of the Database Forums category; I am writing a batch file to create some tables. Two or more of these tables have a field called ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2007
pietromas@gmail.com
 
Posts: n/a
Default Factoring Enum Out of Code

I am writing a batch file to create some tables. Two or more of these
tables have a field called category which should be an ENUM. As its a
big ENUM, say 100 entries, I dont like to reproduce its definition
twice. Is there any preprocessing syntax that can be used to improve
the code?

Have:

CREATE TABLE t1 (
category ENUM ( ... ),
....
)

CREATE TABLE t2 (
category ENUM ( ... ),
....
)

Conceptually I want:

CATEGORY_ENUM = ENUM (...)

CREATE TABLE t1 (
category CATEGORY_ENUM,
....
)

CREATE TABLE t2 (
category CATEGORY_ENUM,
....
)

Reply With Quote
  #2 (permalink)  
Old 05-24-2007
Captain Paralytic
 
Posts: n/a
Default Re: Factoring Enum Out of Code

On 24 May, 10:47, pietro...@gmail.com wrote:
> I am writing a batch file to create some tables. Two or more of these
> tables have a field called category which should be an ENUM. As its a
> big ENUM, say 100 entries, I dont like to reproduce its definition
> twice. Is there any preprocessing syntax that can be used to improve
> the code?
>
> Have:
>
> CREATE TABLE t1 (
> category ENUM ( ... ),
> ....
> )
>
> CREATE TABLE t2 (
> category ENUM ( ... ),
> ....
> )
>
> Conceptually I want:
>
> CATEGORY_ENUM = ENUM (...)
>
> CREATE TABLE t1 (
> category CATEGORY_ENUM,
> ....
> )
>
> CREATE TABLE t2 (
> category CATEGORY_ENUM,
> ....
> )


With that size of ENUM firld, I would be looking at a separate
Category table instead.

Reply With Quote
  #3 (permalink)  
Old 05-24-2007
pietromas@gmail.com
 
Posts: n/a
Default Re: Factoring Enum Out of Code

On May 24, 11:01 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 24 May, 10:47, pietro...@gmail.com wrote:
>
>
>
> > I am writing a batch file to create some tables. Two or more of these
> > tables have a field called category which should be an ENUM. As its a
> > big ENUM, say 100 entries, I dont like to reproduce its definition
> > twice. Is there any preprocessing syntax that can be used to improve
> > the code?

>
> > Have:

>
> > CREATE TABLE t1 (
> > category ENUM ( ... ),
> > ....
> > )

>
> > CREATE TABLE t2 (
> > category ENUM ( ... ),
> > ....
> > )

>
> > Conceptually I want:

>
> > CATEGORY_ENUM = ENUM (...)

>
> > CREATE TABLE t1 (
> > category CATEGORY_ENUM,
> > ....
> > )

>
> > CREATE TABLE t2 (
> > category CATEGORY_ENUM,
> > ....
> > )

>
> With that size of ENUM firld, I would be looking at a separate
> Category table instead.


Thats a helpful suggestion thanks, but for arguments sake is what I
originally asked about possible in any way?

Reply With Quote
  #4 (permalink)  
Old 05-26-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Factoring Enum Out of Code

pietromas@gmail.com wrote:
> On May 24, 11:01 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>> On 24 May, 10:47, pietro...@gmail.com wrote:
>>
>>
>>
>>> I am writing a batch file to create some tables. Two or more of these
>>> tables have a field called category which should be an ENUM. As its a
>>> big ENUM, say 100 entries, I dont like to reproduce its definition
>>> twice. Is there any preprocessing syntax that can be used to improve
>>> the code?
>>> Have:
>>> CREATE TABLE t1 (
>>> category ENUM ( ... ),
>>> ....
>>> )
>>> CREATE TABLE t2 (
>>> category ENUM ( ... ),
>>> ....
>>> )
>>> Conceptually I want:
>>> CATEGORY_ENUM = ENUM (...)
>>> CREATE TABLE t1 (
>>> category CATEGORY_ENUM,
>>> ....
>>> )
>>> CREATE TABLE t2 (
>>> category CATEGORY_ENUM,
>>> ....
>>> )

>> With that size of ENUM firld, I would be looking at a separate
>> Category table instead.

>
> Thats a helpful suggestion thanks, but for arguments sake is what I
> originally asked about possible in any way?
>


No.

But any halfway decent text editor will allow you to copy/paste.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0