------=_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--
Comment