Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
Factoring Enum Out of Code
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default Factoring Enum Out of Code - 06-04-2007, 07:58 AM

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,
....
)

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Factoring Enum Out of Code
Old
  (#2)
Captain Paralytic
Guest
 
Posts: n/a
Default Re: Factoring Enum Out of Code - 06-04-2007, 07:58 AM

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.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Factoring Enum Out of Code
Old
  (#3)
Guest
Guest
 
Posts: n/a
Default Re: Factoring Enum Out of Code - 06-04-2007, 07:58 AM

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?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Factoring Enum Out of Code
Old
  (#4)
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Factoring Enum Out of Code - 06-04-2007, 07:58 AM

EMAIL REMOVED 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.
EMAIL REMOVED
==================
   
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

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




Contact Us - Forum Care Forums - Archive - Top