Creating database fields from Struct(FORM)

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Creating database fields from Struct(FORM)

    I have a survey that has a few questions which change every month. I am looking
    for a way to edit the HTML only and add the relevant FORM variables, and then
    have the system do the rest i.e. create the neccasary variables and then submit
    the information.

    Here is what I have as a script to generate the database fields...

    <cfset VARIABLES.dbScript = "create table survey (">
    <cfset VARIABLES.firstLoop = "True">
    <cfloop list="#structKeyList(FORM)#" index="currentKey">
    <cfscript>
    if (VARIABLES.firstLoop IS "True")
    {
    VARIABLES.dbScript = VARIABLES.dbScript &
    currentKey & " VARCHAR2(50)";
    VARIABLES.firstLoop = "False";
    }
    else
    {
    VARIABLES.dbScript = VARIABLES.dbScript & ", " &
    currentKey &
    " VARCHAR2(50)";
    }
    </cfscript>
    </cfloop>
    <cfset VARIABLES.dbScript = VARIABLES.dbScript & ")">


    This is supposed tol generate a simple script for building my database (that's
    a simplified Oracle syntax) It's horribly inefficient use of storage, but I
    want quick and easy so...

    Can I use and modify the procedure above to generate an insert statement from
    the form variables? This will actually be my action page, whereas step 2 is
    just a widget to help you create the table.

    Does this make sense? What I am trying to do is build the survey form, then
    using the widget I created in step 2 to build a script to create storage for
    the form, simply by filling it out and submitting it to the widget. Then I use
    the code in step 3 as my action page, and it will stuff the form fields into
    your database.

    Will this work? Is this a good idea? Any other suggestions?



    Niles Runeberg Guest

  2. Similar Questions and Discussions

    1. Dynamically creating fields in a flex form
      Hello frieds, I am wondering if it would be possible with Flex to dynamically generate a form by quering a small databse that would return via...
    2. Putting identical form fields into database
      I want to add a new entry to my database.. I have the form with all the fields ready. However for one particular field, i want to have a drop...
    3. Dynamically creating form fields from DB
      Hi All I've just been doing a basic Contact Us form and having actually structured it for a change I noticed that a lot of repetitive and could...
    4. Issues with declaring struct arrays inside of a struct
      I have the following C++ code: define MAXXPAXX 64 // Pack sub component of database struct. typedef PREFIX_PACKED struct { DWORD packid;...
    5. Calling fun taking struct and not pointer to struct?
      Robert Feldt wrote: I'm a little confused by the question... are you asking if: 1) The act of using a struct in the declaration of another...
  3. #2

    Default Re: Creating database fields from Struct(FORM)

    Should I rephrase the question?
    Niles Runeberg Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139