Lade...
 

Query Beispiel

// Example 1 - simple query String(CX_PERSON::name, 12, 12, 120) Button(b1, 132, 12, "?") [ SELECT: GetValue(, name) "name = %STRING" FindFirst(CX_PERSON) FillWindow ] // Example 2 - (non-indexable) dynamic datafields and constant "mother.description = \"decscribing the object ...\"" FindFirst(CX_PERSON) // Example 3 - indexable dynamic datafield "credit > 2500.00DM" Find(CX_PERSON) // Example 4 - calling a query function "HasBirthday() = 1" Find(CX_PERSON) // Example 5 - nested query // Tell the Query manager the class of the objects found in this collection "structures" "CX_PERSON" GetManager(QUERY) Call(CollectionContains) // Start query GetValue "structures[:name = %s:]" FindFirst(CX_PERSON) // Example 6 - Retrieve "Retrieve(LastUpdate()) = %CX_DATE" Find(CX_PERSON) // Example 7 - // InstantView® code to let the query manager display the queries of example 1 to 6 Header(h, 12, 56, 700, 9, obx) { Prompt(GetCollTypeName(), FONT(0), 0, 1, "Class") Prompt(QueryString(), FONT(0), RED, 100, 1, "OStore query Expression") Prompt(GetLRUCount(), FONT(0), 234, 1, "LRU Count") } ObjectList(obx, AUTO_POSITION, ITEM(, 13), 12, 66, 700, 50) [ INITIALIZE: [ "CX_QUERY::GetCollTypeName()" NO_DRAIN ] SetFormat [ "CX_QUERY::QueryString()" COLOR LIGHTRED ] SetFormat [ "CX_QUERY::GetMode()" COLOR GREEN NO_DRAIN ] SetFormat [ "CX_QUERY::GetLRUCount()" NO_DRAIN ] SetFormat [ "CX_QUERY::GetOriginalQueryString()", 0, 7, NO_DRAIN, COLUMN 1, COLOR BLUE ] SetFormat GetManager(QUERY) Call(GetCachedQueries) UpdateObox ] Header(f, 12, 117, 700, 9, obx) { Prompt(GetOriginalQueryString(), FONT(0), BLUE, 0, 0, "Query expression") }

q.bmp (434538 Byte)

// Example 8 -
// einige Beispiele für Queries mit Pattern Matching

"name ~ \"A*\"" Find(CX_PERSON)       // Findet alle Personen, deren Name mit A beginnt
"A*" "name ~ %s" Find(CX_PERSON)      // s.o., der Suchausdruck wird auf den Stack gelegt
"Retrieve(UniqueID()) ~ \"U*\""       // Retrieve() kann in Queries benutzt werden!
"name = \"Schmidt\" | name ~ \"A*\""  // Findet alle Schmidts und Personen mit A...
p "this @ %CX_PERSON | name ~ \"A*\"" // Findet alle Personen mit A... und das Objekt 'p'
"ordinalNumber = 456 | name ~ \"A*\"" // ...kombiniert mit einem Vergleich von ganzen Zahlen
456 "ordinalNumber = %i"              // ...und als Parameter auf dem Stack übergeben

// Example 9 -
// Beispiele für Queries mit dem ?-Operator

"?father" Find(CX_PERSON)             // Findet alle Personen, die einen Vater haben
"?father.father" Find(CX_PERSON)      // Findet alle Personen, die einen Großvater haben
"!?comment" Find(CX_PERSON)           // Findet alle Personen, die keinen Kommentar haben

Einträge in CLASSIX.INI

für Beispiel  
4 Index(credit, 6)
6 Retrieve(\"LastUpdate()\", 6)
// Example 10 - // Beispiele für das Aufrufen eines Makros in Queries Define(RetrieveInteger1) Copy(uniqueID) "cx" = ; "Retrieve(call(RetrieveInteger1))=1" Find(CX_USER)