I am using Visual FoxPro 9.0 trying to create a program to update a field in a MS SQL 2000 DB from another field in another DB. The InvMaster DB contains inventory information with a field named AlternateKey1 used to store UPC codes. The UPCSTORE DB contains a list of codes to be used in the inventory DB. The idea is to insert an un-used code in the inventory DB for fields that are blank and then mark the used code in the UPCSTORE DB as used.
My problem is that no updates are actually happening, I know I am missing something with allowing VFP to update the SQL files, but I have not been able to figure it out.
I will greatly appreciate any input you can provide.
Note: For now I have the code setup to only update one record in each DB for testing, eventually once I work this problem out I will set it up with a DO WHILE loop to do a batch update.
* Program.: UPCFox.PRG V1.0
*
CLOSE ALL
SET DEFAULT TO C:\Data\UPCFOX\Dbfs
*
DELETE FILE C:\Data\UPCFOX\Dbfs\vupcstore*.*
DELETE FILE C:\Data\UPCFOX\Dbfs\vinventory*.*
*
CREATE DATABASE vupcstore
CREATE SQL VIEW vupcstore;
REMOTE CONNECTION LocalSyspro;
AS SELECT UPC, USED, DATEUSED FROM UPCSTORE
DBSETPROP ("vupcstore", "View", "SendUpdates", .T.)
DBSETPROP("vupcstore.used", "Field", "Updatable", .T.)
DBSETPROP("vupcstore.dateused", "Field", "Updatable", .T.)
DBSETPROP("vupcstore.used", "Field","KeyField",.T.)
SELECT 1
USE vupcstore
INDEX ON UPC TO UPCSTORE
SET FILTER TO USED <>'Y'
GO TOP
m.upc=upc
*
CREATE DATABASE vinventory
CREATE SQL VIEW vinventory;
REMOTE CONNECTION LocalSyspro;
AS select StockCode, Description, AlternateKey1 FROM InvMaster
DBSETPROP ("vinventory", "View", "SendUpdates", .T.)
DBSETPROP("vinventory.alternatekey1", "Field", "Updatable", .T.)
*
SELECT 2
*
USE vinventory
INDEX on StockCode TO vinventory
SET FILTER TO LEFT(AlternateKey1,2) <>"64"
GO TOP
m.stock=StockCode
*
REPLACE AlternateKey1 WITH m.upc FOR StockCode=m.stock
*
TABLEUPDATE()
*
SELECT 1
*
REPLACE used WITH "Y" FOR upc=m.upc
REPLACE dateused WITH DATE() FOR upc=m.upc
*
TABLEUPDATE()
*
CLOSE DATABASES
SET DEFAULT TO C:\Data\UPCFOX\Prgs
*
RETURN
*
* EOF: UPCFox.PRG
My problem is that no updates are actually happening, I know I am missing something with allowing VFP to update the SQL files, but I have not been able to figure it out.
I will greatly appreciate any input you can provide.
Note: For now I have the code setup to only update one record in each DB for testing, eventually once I work this problem out I will set it up with a DO WHILE loop to do a batch update.
* Program.: UPCFox.PRG V1.0
*
CLOSE ALL
SET DEFAULT TO C:\Data\UPCFOX\Dbfs
*
DELETE FILE C:\Data\UPCFOX\Dbfs\vupcstore*.*
DELETE FILE C:\Data\UPCFOX\Dbfs\vinventory*.*
*
CREATE DATABASE vupcstore
CREATE SQL VIEW vupcstore;
REMOTE CONNECTION LocalSyspro;
AS SELECT UPC, USED, DATEUSED FROM UPCSTORE
DBSETPROP ("vupcstore", "View", "SendUpdates", .T.)
DBSETPROP("vupcstore.used", "Field", "Updatable", .T.)
DBSETPROP("vupcstore.dateused", "Field", "Updatable", .T.)
DBSETPROP("vupcstore.used", "Field","KeyField",.T.)
SELECT 1
USE vupcstore
INDEX ON UPC TO UPCSTORE
SET FILTER TO USED <>'Y'
GO TOP
m.upc=upc
*
CREATE DATABASE vinventory
CREATE SQL VIEW vinventory;
REMOTE CONNECTION LocalSyspro;
AS select StockCode, Description, AlternateKey1 FROM InvMaster
DBSETPROP ("vinventory", "View", "SendUpdates", .T.)
DBSETPROP("vinventory.alternatekey1", "Field", "Updatable", .T.)
*
SELECT 2
*
USE vinventory
INDEX on StockCode TO vinventory
SET FILTER TO LEFT(AlternateKey1,2) <>"64"
GO TOP
m.stock=StockCode
*
REPLACE AlternateKey1 WITH m.upc FOR StockCode=m.stock
*
TABLEUPDATE()
*
SELECT 1
*
REPLACE used WITH "Y" FOR upc=m.upc
REPLACE dateused WITH DATE() FOR upc=m.upc
*
TABLEUPDATE()
*
CLOSE DATABASES
SET DEFAULT TO C:\Data\UPCFOX\Prgs
*
RETURN
*
* EOF: UPCFox.PRG