Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UPDATE FROM SQL PASSTHROUGH TO DBF TABLE
Message
From
30/10/2001 08:38:48
 
 
To
30/10/2001 00:22:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00574878
Message ID:
00574967
Views:
24
>Hello people,
>I have a FoxPro table created from a table in a Pervassive.sql database using SQL PASSTHROUGH. My question is how can I now update the DBF using SQL PASSTHROUGH?
>
>Map
>PERVASSIVE ITEM TABLE >> UPDATE(using SQL PASSTHROUGH) INTO DBF WITH CHANGES/NEW
>Thanks.

I'm not sure what you are trying to do, but if you merely want to look at data from another datasource, why not just use a remote view and requery it?


If you need to use SPT to update a remote datasource, do something like this:
lnHandle=SQLCONNECT("MyDataSource")
lnResult=SQLEXEC(lnHandle,[SELECT * FROM MyTable],"MyTable")
IF lnResult<1
   =AERROR(Errors)   && Handle errors gracefully
   =oErrors.Msg()    && if something goes wrong
   RETURN lnResult
ENDIF

llResult=CURSORSETPROP("Tables","MyTable","MyTable")
IF llResult=.F.
   =AERROR(Errors)
   =oErrors.Msg()
   RETURN lnResult
ENDIF

***
* lcUpdateList comes in handy if you have a lot of fields
* lcFields1="Field1 TableName.Field1,....Field(n) Tablename.Field(n)"
* Because of FP string-length limitations you then have to do a
* lcUpdateList=lcFields1+lcFields2+...lcFields(n)
* Below is the simple version
***

lcUpdateList="Field1 MyTable.Field1,Field2 MyTable.Field2"
llResult=CURSORSETPROP("UpdateNameList",lcUpdateList,"MyTable")
IF llResult=.F.
  =AERROR(Errors)
  =oErrors.Msg()
  RETURN lnResult
ENDIF

llResult=CURSORSETPROP("KeyFieldList","Field1,Field2,"MyTable")
IF llResult=.F.
  =AERROR(Errors)
  =oErrors.Msg()
  RETURN lnResult
ENDIF

llResult=CURSORSETPROP("UpdatableFieldList","Field1,Field2","MyTable")
IF llResult=.F.
  =AERROR(Errors)
  =oErrors.Msg()
  RETURN lnResult
ENDIF

llResult=CURSORSETPROP("Buffering",5,"MyTable")
IF llResult=.F.
  =AERROR(Errors)
  =oErrors.Msg()
  RETURN lnResult
ENDIF
Now you can insert, update, delete and what not, and in the end just issue
llResult=TABLEUPDATE(2,.T.,"MyTable",Errors)
and lo and behold, if all goes well, your stuff is updated!


HTH
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Previous
Reply
Map
View

Click here to load this message in the networking platform