Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdapter refresh from stored procedure
Message
De
25/04/2005 14:40:05
 
 
À
25/04/2005 06:33:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01007506
Message ID:
01008185
Vues:
16
Hi David,

I believe VFPOLEDB doesn't support binding to stored procedure's return value. You can trick CursorAdapter and execute the insert procedure as if it was a refresh procedure. CursorAdapter expects a RecorSet from refresh command and modifies fields based on its content.
CLEAR
CLOSE DATABASES all

CREATE TABLE TestAutoRefresh (f1 I AUTOINC NEXTVAL (-5000) STEP (5), f2 I)
USE

cProc = ""

STRTOFILE(cProc,"DoNothing.PRG")


TEXT TO cProc NOSHOW
PARAMETERS f2_Val
INSERT into TestAutoRefresh (f2) values (m.f2_Val)
RETURN GetAutoIncVal(0)
ENDTEXT

STRTOFILE(cProc,"DoInsert.PRG")

LOCAL oConn as ADODB.Connection, oRS as ADODB.Recordset, oCom as ADODB.Command

oConn=CREATEOBJECT("ADODB.Connection")
oConn.Open("Provider=VFPOLEDB.1;Data Source="+SYS(5)+CURDIR())

oCom = CREATEOBJECT("Adodb.Command")
oCom.ActiveConnection = oConn

oRS = CREATEOBJECT("Adodb.Recordset")
oRS.ActiveConnection = oConn
oRS.CursorLocation= 3  && adUseClient
oRS.LockType= 1  && adLockReadOnly

LOCAL oCA as CursorAdapter

oCA=CREATEOBJECT("CursorAdapter")
oCA.Alias="test"
oCA.DataSourceType="ADO"
oCA.DataSource=oRS
oCA.SelectCmd="select * from TestAutoRefresh"
oCA.InsertCmdDataSourceType="ADO"
oCA.InsertCmdDataSource=oCom
oCA.InsertCmd="EXEC DoNothing()"

oCA.InsertCmdRefreshCmd="EXEC DoInsert(?test.f2)"
oCA.InsertCmdRefreshFieldList="f1"

?oCA.CursorFill()

INSERT into test (f2) values (10)
INSERT into test (f2) values (20)
INSERT into test (f2) values (30)

LIST

?oCA.CursorRefresh()
LIST
USE
Thanks,
Aleksey.



>Hi Aleksey,
>
>Thank you very much for your enlightments !
>
>
>>However, there are other ways to refresh field(s) during TABLEUPDATE:
>1. You can bind fields to output parameters and/or to the result of stored procedure (an example is below).
>
>This seems to be a very fine way to do it. Unfortunately, I could not make it work yet because I am working with a VFP back-end and I didn't find the syntax with which I could bind a VFP variable to the result of the stored procedure. Up to now, I have always retrieved that result by using the call syntax "EXEC #test_ins_2()" and analyzing the returned RecordSet. The syntax "EXEC ?@test.f1 = #test_ins_2" doesn't seem to be the right one against a VFP database. Do you know which one I should use ?
>
>I also thought about the other methods you gave, but if that one worked with a VFP database it would be my preferred.
>
>Greetings,
>
>David
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform