SQL server question

Discussion in 'UK Motorcycles' started by flash, Jan 12, 2005.

  1. flash

    flash Guest

    I have a sql server 2000 database with a custom rule defining a list of
    types for a variable;

    something like "@list IN ('paper', 'stone', 'scissors')"

    I have then created a datatype using this rule.

    Want I want to do is (in a aspx page) extract the type list from my rule so
    I can generate a dropdown list of types. ie the user would pick one of the
    types when entering a record. I don't want to hardcode the types in case my
    rule changes.

    Any clues? Anyone?
     
    flash, Jan 12, 2005
    #1
    1. Advertisements

  2. flash

    dwb Guest

    Not off the top of my head and not going to look it up right now :)

    A 'stupid' solution wuld be to create a lookup table that your page calls
    instead.
    You can then just add a record to the lookup table when you want to add an
    option.
     
    dwb, Jan 12, 2005
    #2
    1. Advertisements

  3. flash

    darsy Guest

    well, I have two answers.

    a) The info you need is probably in the system metadata tables.

    b) Your application architecture is very flawed. What I would do, to
    accomplish the functionality you outline above would be something like:

    1. Create a lookup table, with a (n ideally abstract, or at least
    ascending numerical) primary key, and another column called something
    like lookupValue. In this table, I'd have 3 (your example) rows, with
    "paper", "stone" and "scissors" in the lookupValue column.

    2. In the other table, where you'd previously have had your custom
    datatype, I'd have a varchar (or numeric, if you've not taken my advice
    and used an abstract key), and you'd store the primary key
    corresponding to the value in the lookup table.

    3. Then, in your ASP, you do a SELECT lookupValue FROM lookupTable and
    loop over the record-set to populate your dropdown, with the
    (hopefully) abstract key as the value of each select option.

    What are the advantages of the above over your approach? Several,
    including:

    * The list of possible values is not necessarily maintained by the DBA
    - you could create a "Backend" web app to maintain the allowed values
    * your code becomes database agnostic, and hence more portable
    * It solves your problem without any dicking around in metadata
     
    darsy, Jan 12, 2005
    #3
  4. flash

    darsy Guest

    Oy!

    The word is "pragmatic", not "stupid" ... ;-)
     
    darsy, Jan 12, 2005
    #4
  5. flash

    HooDooWitch Guest

    "darsy" <> somehow managed to post:

    *a ding, a ding, ring-a-ding, fraaaaap, bwaaaaaa*
     
    HooDooWitch, Jan 12, 2005
    #5
  6. flash

    flash Guest

    <Holds up hands>. Its a fair cop, I was seduced by the whole clicky sql
    server thing.
     
    flash, Jan 12, 2005
    #6
  7. flash

    dwb Guest

    True true.

    My current favourite is "we're currently enhancing that feature" instead of
    "we've sold the product as having it, but it appears it doesn't"
     
    dwb, Jan 12, 2005
    #7
  8. flash

    darsy Guest

    heh - I got away with "oh, that set of features was dropped from this
    release, as it made more sense to do the work at the same time as some
    other stuff - weren't you at the meeting when this was agreed?"

    Bullshit baffles brains (not that the person I was speaking to is
    overly-endowed in the grey-matter department).
     
    darsy, Jan 12, 2005
    #8
  9. flash

    mups Guest

    darsy says...
    "If you can't dazzle them with brilliance, baffle them with bullshit"
     
    mups, Jan 12, 2005
    #9
  10. flash

    Champ Guest

    That's the basis of my whole career!
    --
    Please add "imo" to above post.
    Champ
    GSX-R 1000, GPz 750 turbo, ZX7RR Endurance Racer x 2
    GYASB#0 BotToS#2 BOTAFO(T|F)#35 WG*#1 DFV#8
    Team UKRM Racing : www.team-ukrm.com
     
    Champ, Jan 12, 2005
    #10
  11. flash

    mups Guest

    Champ says...
    *ding*
     
    mups, Jan 12, 2005
    #11
  12. ^^^^^^^
    'descoped'
     
    Richard Giles, Jan 12, 2005
    #12
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.