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:
01410701
Vues:
38
>>>Hi everybody,
>>>
>>>I have a junction table that is supposed to have
>>>
>>>OptionID MakeID ModelID and some price fields.
>>>
>>>I have one OptionID and one MakeID selected and I can have multiple ModelID selected.
>>>
>>>I want to have a view (or CA) which would have records for each of them, e.g.
>>>
>>>selOptionID selMakeID selModelID1         Price fields
>>>selOptionID selMakeID selModelID2         Price fields
>>>
>>>
>>>If I already have a record in my table, I want to retrieve it, otherwise prepare a record to fill.
>>>
>>>Also I want to be able to cancel at any moment and therefore new records would not be added.
>>>
>>>I'm not sure how to construct such view or CA.
>>>
>>>Any ideas?
>>>
>>>Thanks in advance.
>>
>>
>>*** SelectCmd
>>
>>SELECT * (or field list)
>>      FROM YourTable
>>WHERE OptionID = ?m.selOptionID AND
>>      MakeId   = ?m.selMakeID   AND
>>      ModelId IN (?m.lnModel1, ?m.lnModel2, ?m.lnModel3...?m.lnModelN) && what is the biggest number of models?
>>
>
>Here I don't know how many models I select. How can I make this dynamic?
>
>I haven't checked the max number, but may be ~100 Models at most.
>
>
>>*** AfterCursorFill and AfterCursorRefresh() events
>>IF lResult
>>   this.CheckForRecors()
>>ENDIF
>>
>>***  CheckForRecors method of the CA
>>IF RECCOUNT(this.Alias) == 0
>>   APPEND BLANK IN (this.Alias)
>>ENDIF
>>
>
>
>We need a record for each passed ModelID, not just one.
>
>
>>Of course it should be table buffered and you always can have TABLEREVERT() when you don't want to store record.
>>That is VERY rough example, but you know what I mean :-)
>
>Thanks again.

And that SELECT will give you these :-)
If you(user) selects these - ModelIds 1,7,12,225 for OptionID = 1 AND MakeId = 12

Then SELECTCmd will look like this:
selOptionID = 1
selMakeID   = 12
STORE 0 TO m.lnModel1, m.lnModel2, m.lnModel3...m.lnModelN
m.lnModel1 = 1
m.lnModel2 = 7
m.lnModel3 = 12
m.lnModel4 = 225

SELECT *
      FROM YourTable
WHERE OptionID = ?m.selOptionID AND
      MakeId   = ?m.selMakeID   AND
      ModelId IN (?m.lnModel1, ?m.lnModel2, ?m.lnModel3...?m.lnModelN)
Finaly this will be executed:
SELECT *
      FROM YourTable
WHERE OptionID = 1  AND
      MakeId   = 12 AND
      ModelId IN (1, 7, 12, 225,0....,0)
Which gave you a row for each ModelId, isn't it?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform