Announcement

Collapse
No announcement yet.

Adding new fields to an existing database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding new fields to an existing database



    I have been working on an application and as I realize new needs, the
    best solution would be to create a new field in one of my xbase3
    databases. Is it possible with out loosing everything in the database
    to add one new field?

    --
    Andrew Rosborough <[email protected]>



    #2
    Adding new fields to an existing database



    > I have been working on an application and as I realize new needs, the
    > best solution would be to create a new field in one of my xbase3
    > databases. Is it possible with out loosing everything in the database
    > to add one new field?

    Well, the usual technique is to create a new database file with the
    additional field(s) and then
    copy over the contents with an MvWHILE loop.
    Please have a look at any MM module where the Module_Store_Update functio=
    n
    is not trivial.

    Best,

    Mikl=F3s

    Mikl=F3s Priszny=E1k
    ---
    LPDocS: PDF document service for Miva Merchants <A HREF ="http://www.lpdocs.com">http://www.lpdocs.com</A>
    Make a PDF store newsletter/catalog straight from your Miva store for les=
    s
    than five dollars!
    Payment is via PayPal, e-gold or StormPay
    <A HREF ="http://www.mivacentral.com/prod.mv?LPDOCS-LPNL">http://www.mivacentral.com/prod.mv?LPDOCS-LPNL</A>

    New Customer Mails: "double-decker" welcome and notification mails
    <A HREF ="http://www.mivacentral.com/prod.mv?LPDOCS-LPCMAIL">http://www.mivacentral.com/prod.mv?LPDOCS-LPCMAIL</A>


    Comment


      #3
      Adding new fields to an existing database



      If you do not need to do it programmatically, you can also change the
      structure quicker in a suitable xBase editor. My favourite one is MS =
      FoxPro,
      but it is certainly possible with others too.

      Ivo
      http://mivo.truxoft.com=20


      -----Original Message-----
      From: Jegenye 2001 Bt

      > I have been working on an application and as I realize new needs, the
      > best solution would be to create a new field in one of my xbase3
      > databases. Is it possible with out loosing everything in the database
      > to add one new field?

      Well, the usual technique is to create a new database file with the
      additional field(s) and then
      copy over the contents with an MvWHILE loop.
      Please have a look at any MM module where the Module_Store_Update =
      function
      is not trivial.

      Best,

      Mikl=F3s



      Comment


        #4
        Adding new fields to an existing database



        >If you do not need to do it programmatically, you can also change the
        >structure quicker in a suitable xBase editor. My favourite one is MS
        FoxPro,
        >but it is certainly possible with others too.

        >Ivo

        Oh, yes, you're certainly right. My choice is "Database Desktop" from
        Borland... because that happens to be installed with Delphi. :-)

        Best,
        Mikl=F3s


        Comment


          #5
          Adding new fields to an existing database



          I wrote up a quick script. For reference it finally worked like this:

          <MvOPEN
          NAME="users"
          DATABASE="users.dbf"
          TYPE="xbase3"
          INDEX="users.mvx">
          <MvOPEN
          NAME="oldusers"
          DATABASE="oldusers.dbf"
          TYPE="xbase3"
          INDEX="oldusers.mvx">

          <MvGO NAME="oldusers" ROW="top">
          <MvWHILE EXPR="{NOT oldusers.d.eof}">
          &[oldusers.d.username];

          <MvASSIGN NAME="users.d.username" VALUE="{oldusers.d.username}">
          <MvASSIGN NAME="users.d.password" VALUE="{oldusers.d.passworde}">
          <MvASSIGN NAME="users.d.email" VALUE="{oldusers.d.email}">
          <MvADD NAME="users">
          <MvSKIP NAME="oldusers">
          </MvWHILE>

          <MvCLOSE NAME="oldusers">
          <MvCLOSE NAME="users">

          --
          Andrew Rosborough <[email protected]>


          Comment


            #6
            Adding new fields to an existing database



            I do it all the time.

            1. MvCREATE a new db with the extra field(s)
            2. Open the old DB
            3. Cycle through the old db using MvWHILE
            4. On each record, copy the existing data from the old db into the new
            one and initialize the new field any way you want.
            5. Reneame the new db to the name of the old one, and that's it.

            Scot

            Andrew Rosborough wrote:
            > I have been working on an application and as I realize new needs, the
            > best solution would be to create a new field in one of my xbase3
            > databases. Is it possible with out loosing everything in the database
            > to add one new field?
            >

            --
            ------------

            "To The States, or any one of them, or any city of The States,
            Resist much, obey little;
            Once unquestioning obedience, once fully enslaved;
            Once fully enslaved, no nation, state, city, of this earth,
            ever afterward resumes its liberty."

            ~Walt Whitman

            Comment

            Working...
            X