Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to come up with a view/CA model
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01410693
Message ID:
01410965
Vues:
43
>>>>BTW if you want the AutoInc field to be automatically populated after insert/update you should add these 4 properties:
>>>>
>>>>InsertCmdRefreshFieldList = "OPTSID"
>>>>UpdateCmdRefreshFieldList = "OPTSID"
>>>>InsertCmdRefreshCmd       = "SELECT OPTSID FROM DealerOpts WHERE OPTSID = GETAUTOINCVALUE()"
>>>>UpdateCmdRefreshCmd       = "SELECT OPTSID FROM DealerOpts WHERE OPTSID = GETAUTOINCVALUE()"
>>>>
>>>
>>>Are you sure we need UPDATE commands here too?
>>
>>Almost :-)
>>Don't forget that we changed UPDATE to INSERT in some condition, but NOT tested :-)
>
>It is still gives me "Syntax error".
>
>Here is the current code:
>
>
>DEFINE CLASS cadealeropts AS cursoradapter_
>
>
>	SelectCmd = "select DealerOpts.OptsID, NVL(DealerOpts.OptionID,?getOptionID) as OptionID,  
>NVL(DealerOpts.MakeID, ?getMakeID) as MakeID, Models.ModelID as ModelID, Models.MfgName, 
>Models.Name as ModelName, Models.ModelNmbr as ModelNmbr,  Models.ModelYear as ModelYear, 
>CAST(NVL(DealerOpts.Retail,0) as N(10,2)) as Retail, CAST(NVL(DealerOpts.Cost,0) as N(10,2)) as Cost, 
>CAST(NVL(DealerOpts.Costline,0) as N(10,2)) as CostLine, 
>CAST(NVL(DealerOpts.cType,'') as C(12)) as cType, 
>NVL(DealerOpts.StdOption,.F.) as StdOption from DealerOpts 
>RIGHT JOIN Models ON DealerOpts.ModelID = Models.ModelID and 
>DealerOpts.OptionID = ?getOptionID and DealerOpts.MakeID = ?getMakeID 
>where cast(Models.ModelID as varchar(12)) $ (?getModelIDs)"
>	CursorSchema = "OptsID I, OptionID I, MakeID I, ModelID I, MfgName C(40), 
>ModelName C(65), ModelNmbr C(20), ModelYear C(40), Retail N(10, 2), Cost N(10, 2), 
>Costline N(10, 2), cType C(12), StdOption L(1)"
>	Alias = "curdealeropts"
>	DataSourceType = "Native"
>	InsertCmdDataSourceType = "Native"
>	UpdateCmdDataSourceType = "Native"
>	DeleteCmdDataSourceType = "Native"
>	Flags = 0
>	CompareMemo = .T.
>	FetchMemo = .F.
>	SendUpdates = .T.
>	KeyFieldList = "OPTSID"
>	Tables = "DealerOpts,Models"
>	UpdatableFieldList = "OPTIONID, MAKEID, MODELID, RETAIL, COST, COSTLINE, CTYPE, STDOPTION"
>	UpdateNameList = "OPTSID DealerOpts.OPTSID, OPTIONID DealerOpts.OPTIONID, 
>MAKEID DealerOpts.MAKEID, MODELID DealerOpts.MODELID, 
>RETAIL DealerOpts.RETAIL, COST DealerOpts.COST, COSTLINE DealerOpts.COSTLINE, 
>CTYPE DealerOpts.cType, STDOPTION DealerOpts.STDOPTION"
>	BreakOnError = .T.
>	UseCursorSchema = .T.
>	UseTransactions = .T.
>	Name = "cadealeropts"
>
>
>	PROCEDURE BeforeUpdate
>		LPARAMETERS cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd
>		IF ISNULL(EVALUATE(this.Alias +[.OPTSID]))
>		           TEXT TO cUpdateInsertCmd NOSHOW TEXTMERGE PRETEXT 15
>		                INSERT INTO DealerOpts (OptionID, MakeID, Retail, Cost, Costline, Type, StdOption, ModelID)
>		                VALUES
>		                (<<EVALUATE(this.Alias+[.OptionID])>>,
>		                 <<EVALUATE(this.Alias+[.MakeID])>>,
>		                 <<EVALUATE(this.Alias+[.Retail])>>,
>		                 <<EVALUATE(this.Alias+[.Cost])>>,
>		                 <<EVALUATE(this.Alias+[.Costline])>>,
>		                 <<EVALUATE(this.Alias+[.cType])>>,
>		                 <<EVALUATE(this.Alias+[.StdOption])>>,
>		                 <<EVALUATE(this.Alias+[.ModelID])>>)
>		           ENDTEXT
>		ENDIF
>
>		RETURN DODEFAULT(cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd)
>	ENDPROC
>
>
>	PROCEDURE Init
>		*** Setup code: DO NOT REMOVE
>		local llReturn
>		do case
>			case not pemstatus(This, '__VFPSetup', 5)
>				This.AddProperty('__VFPSetup', 0)
>			case This.__VFPSetup = 1
>				This.__VFPSetup = 2
>			case This.__VFPSetup = 2
>				This.__VFPSetup = 0
>				return
>		endcase
>		set multilocks on
>		llReturn = dodefault()
>		*** End of Setup code: DO NOT REMOVE
>		*** Select connection code: DO NOT REMOVE
>
>		local lcDBC
>		lcDBC = 'MNA.DBC'
>		if dbused(lcDBC)
>			set database to (lcDBC)
>		else
>			open database (lcDBC)
>		endif
>		*** End of Select connection code: DO NOT REMOVE
>
>		*** Setup code: DO NOT REMOVE
>		if This.__VFPSetup = 1
>			This.__VFPSetup = 2
>		endif
>		return llReturn
>		*** End of Setup code: DO NOT REMOVE
>	ENDPROC
>
>
>	PROCEDURE AutoOpen
>		*** Setup code: DO NOT REMOVE
>		if not pemstatus(This, '__VFPSetup', 5)
>			This.AddProperty('__VFPSetup', 1)
>			This.Init()
>		endif
>		*** End of Setup code: DO NOT REMOVE
>	ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: cadealeropts
>**************************************************
>
>
>Do you see where may be a problem?
>
>I test it with
>
>oCa= CREATEOBJECT('caDealerOpts')
>set
>USE dealeropts
>BROWSE && It has one record 1 1 1275 as ModelID
>getMakeID = 1
>getOptionID = 1
>getModelIDs = '_1274_1275_1276'
>oCA.CursorFill()
>browse
>
>when I try to change some values in Cost and move to the next record, I get 'Syntax error' right away.

I think I got it. You only put CRLF in your code for readability, but I copied it right away! :))

Ok, let me fix this.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform