Announcement

Collapse
No announcement yet.

Difficulty adding products to products.dbf

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

    Difficulty adding products to products.dbf



    ------=_NextPart_000_001A_01C4E21B.493C4EE0
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable

    Hi,
    =20
    I am working on an application that ties together our product management
    software with our site. I've written the following code to add a new
    product to products.dbf.=20
    =20
    When the script is run we receive the following error:
    =20
    miva/AddNewProduct.mv: Line 42: MvPACK: Runtime Error: Index
    'prd_id.mvx00000001' was created with the UNIQUE flag and the key '1212'
    already exists in the index file miva/AddNewProduct.mv: Line 43: =
    MvCLOSE:
    Runtime Error: Database 'products' is not open=20
    =20
    Where 1212 is the last id listed in prd_id.mvx.
    =20
    However the product is added correctly with unique, increasing id =
    (although
    we have to pack the table through the admin to see them).
    =20
    HOWEVER, when another product is then added through the admin, it's =
    given a
    duplicate id (!!!) and the following error .=20
    =20
    lib/db.mv: Line 4425: MvADD: Runtime Error: Index
    'Merchant2/00000001/prd_id.mvx' was created with the UNIQUE flag and the =
    key
    '1212' already exists in the index file=20
    =20
    Even after packing, this product cannot be seen through the admin, and =
    it
    has to be removed using a script.
    =20
    QUESTION 1: Why isn't the index being updated when I add the products?
    QUESTION 2: Why do I have to use the admin to pack the products file =
    before
    I can see the new products in the admin when I've packed (or tried to) =
    them
    in the script?
    =20
    Much thanks,
    =20
    Melody
    =20
    =20
    /////CODE///////
    <MvCOMMENT>=20
    The function FindMaxId finds the largest id in products.dbf. =20
    </MvCOMMENT>
    =20
    <MvASSIGN NAME=3D"MaxId" VALUE=3D"{FindMaxId() + 1}"> =20
    <MvOPEN NAME=3D"products"
    DATABASE=3D"../mivadata/Merchant2/00000001/products.dbf"
    INDEXES=3D"../mivadata/Merchant2/00000001/prd_id.mvx">
    <MvIMPORT
    FILE=3D"../mivadata/NewProd.txt"
    FIELDS=3D"txtCode, txtName, txtThumbnail, txtImage, txtPrice, txtCost,
    txtDesc"
    DELIMITER=3D"|">
    <MvASSIGN NAME =3D"d.id" VALUE=3D"{MaxId}">
    <MvASSIGN NAME=3D"catcount" VALUE=3D"{0}">
    <MvASSIGN NAME=3D"agrpcount" VALUE=3D"{0}">
    <MvASSIGN NAME=3D"pgrpcount" VALUE=3D"{0}">
    <MvASSIGN NAME=3D"order" VALUE=3D"{MaxId}">
    <MvASSIGN NAME=3D"code" VALUE=3D"{txtCode}">
    <MvASSIGN NAME=3D"name" VALUE=3D"{txtName}">
    <MvASSIGN NAME=3D"thumbnail" VALUE=3D"{txtThumbnail}">
    <MvASSIGN NAME=3D"image" VALUE=3D"{txtImage}">
    <MvASSIGN NAME=3D"price" VALUE=3D"{txtPrice}">
    <MvASSIGN NAME=3D"cost" VALUE=3D"{txtCost}">
    <MvASSIGN NAME=3D"desc" VALUE=3D"{txtDesc}">
    <MvASSIGN NAME=3D"weight" VALUE=3D"{0}">
    <MvASSIGN NAME=3D"taxable" VALUE=3D"{1}">
    <MvASSIGN NAME=3D"active" VALUE=3D"{0}">
    <MvADD>
    <MvPACK NAME=3D"products">
    <MvCLOSE NAME=3D"products">

    ------=_NextPart_000_001A_01C4E21B.493C4EE0--


    #2
    Difficulty adding products to products.dbf



    You have to get the next available product id from the storekey.dbf, and then increment
    that number so when other systems try to update the product table they don't reuses a
    duplicate id.


    -Bruce
    ......................................
    PHOSPHOR Media
    Featuring: StoreMan - A smarter way to manage Miva Merchant(tm) Store Content.
    Download a hassle-free demo today
    <A HREF ="http://www.phosphormedia.com/go.mv?ID=listsm">http://www.phosphormedia.com/go.mv?ID=listsm</A>
    ......................................




    > -----Original Message-----
    > From: [email protected]
    > [mailto:[email protected]]On Behalf Of Candlelight Valley
    > Fabrics
    > Sent: Tuesday, December 14, 2004 7:27 PM
    > To: [email protected]
    > Subject: [mrc] Difficulty adding products to products.dbf
    >
    >
    > Hi,
    >
    > I am working on an application that ties together our product management
    > software with our site. I've written the following code to add a new
    > product to products.dbf.
    >
    > When the script is run we receive the following error:
    >
    > miva/AddNewProduct.mv: Line 42: MvPACK: Runtime Error: Index
    > 'prd_id.mvx00000001' was created with the UNIQUE flag and the key '1212'
    > already exists in the index file miva/AddNewProduct.mv: Line 43: MvCLOSE:
    > Runtime Error: Database 'products' is not open
    >
    > Where 1212 is the last id listed in prd_id.mvx.
    >
    > However the product is added correctly with unique, increasing id (although
    > we have to pack the table through the admin to see them).
    >
    > HOWEVER, when another product is then added through the admin, it's given a
    > duplicate id (!!!) and the following error .
    >
    > lib/db.mv: Line 4425: MvADD: Runtime Error: Index
    > 'Merchant2/00000001/prd_id.mvx' was created with the UNIQUE flag and the key
    > '1212' already exists in the index file
    >
    > Even after packing, this product cannot be seen through the admin, and it
    > has to be removed using a script.
    >
    > QUESTION 1: Why isn't the index being updated when I add the products?
    > QUESTION 2: Why do I have to use the admin to pack the products file before
    > I can see the new products in the admin when I've packed (or tried to) them
    > in the script?
    >
    > Much thanks,
    >
    > Melody
    >
    >
    > /////CODE///////
    > <MvCOMMENT>
    > The function FindMaxId finds the largest id in products.dbf.
    > </MvCOMMENT>
    >
    > <MvASSIGN NAME="MaxId" VALUE="{FindMaxId() + 1}">
    > <MvOPEN NAME="products"
    > DATABASE="../mivadata/Merchant2/00000001/products.dbf"
    > INDEXES="../mivadata/Merchant2/00000001/prd_id.mvx">
    > <MvIMPORT
    > FILE="../mivadata/NewProd.txt"
    > FIELDS="txtCode, txtName, txtThumbnail, txtImage, txtPrice, txtCost,
    > txtDesc"
    > DELIMITER="|">
    > <MvASSIGN NAME ="d.id" VALUE="{MaxId}">
    > <MvASSIGN NAME="catcount" VALUE="{0}">
    > <MvASSIGN NAME="agrpcount" VALUE="{0}">
    > <MvASSIGN NAME="pgrpcount" VALUE="{0}">
    > <MvASSIGN NAME="order" VALUE="{MaxId}">
    > <MvASSIGN NAME="code" VALUE="{txtCode}">
    > <MvASSIGN NAME="name" VALUE="{txtName}">
    > <MvASSIGN NAME="thumbnail" VALUE="{txtThumbnail}">
    > <MvASSIGN NAME="image" VALUE="{txtImage}">
    > <MvASSIGN NAME="price" VALUE="{txtPrice}">
    > <MvASSIGN NAME="cost" VALUE="{txtCost}">
    > <MvASSIGN NAME="desc" VALUE="{txtDesc}">
    > <MvASSIGN NAME="weight" VALUE="{0}">
    > <MvASSIGN NAME="taxable" VALUE="{1}">
    > <MvASSIGN NAME="active" VALUE="{0}">
    > <MvADD>
    > <MvPACK NAME="products">
    > <MvCLOSE NAME="products">
    >
    > ---
    > Incoming mail is certified Virus Free.
    > Checked by AVG anti-virus system (<A HREF =/"http://www.grisoft.com)/">http://www.grisoft.com)</A>.
    > Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/04
    >
    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (<A HREF =/"http://www.grisoft.com)/">http://www.grisoft.com)</A>.
    Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/04


    Comment

    Working...
    X