Forum Post: RE: dynamic query

  • Thread starter Thread starter Ken McIntosh
  • Start date Start date
Status
Not open for further replies.
K

Ken McIntosh

Guest
A dynamic query is one where you do not have to provide the predicate at compile time. The tables and the WHERE clause of a dynamic query can be constructed and executed at runtime, without knowledge of how the query will work at compile-time. Static query example: DEFINE QUERY qCustomer FOR Customer SCROLLING. OPEN QUERY qCustomer FOR EACH Customer WHERE Customer.Name BEGINS " some-value ". Dynamic query example: RUN queryTable ( INPUT "Customer", INPUT "FOR EACH Customer WHERE Customer.Name BEGINS ~" some-value ~"" ). PROCEDURE queryTable: DEFINE INPUT PARAMETER pcTables AS CHARACTER NO-UNDO. DEFINE INPUT PARAMETER pcQuery AS CHARACTER NO-UNDO. DEFINE VARIABLE hQuery AS HANDLE NO-UNDO. DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO EXTENT 20. DEFINE VARIABLE iTable AS INTEGER NO-UNDO. CREATE QUERY hQuery. DO iBuffer = 1 TO NUM-ENTRIES(pcTables): CREATE BUFFER hBuffer[iBuffer] FOR TABLE ENTRY(iBuffer,pcTables). hQuery:ADD-BUFFER(hBuffer[iBuffer]). END. hQuery:QUERY-PREPARE(pcQuery). hQuery:QUERY-OPEN(). ... END PROCEDURE. Below is a link to a Progress knowledgebase article which goes into more detail about the Dynamic Query. knowledgebase.progress.com/.../P102491

Continue reading...
 
Status
Not open for further replies.
Back
Top