You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Current »

QUERY$ returns a Telitab set from an arbitrary database

Syntax

QUERY$(QueryScript$, [InpVar])

Arguments 

  • QueryScript$ is an expression returning a query receipe for the supported database
  • InpVar can be a list of parameters required in the QueryScript$ definition

Remarks

  1. One script is currently supported (see examples for their application):
    • for MS ACCESS;
  1. It is convenient to use the TEXTITEM$() function for QueryScript$, see the examples how to do this;
  2. For details on the script definitions, please revert to the documentation of the related database product
  3. Qnowledge is working on the use of this function for direct query on QDB. Furthermore, we assume that SQL queries can be implemented comparable to the MS ACCESS queries. On request we can investigate this.

Examples

Example of an ACCESS query script

We want to get information from an MS ACCESS database with filename "DrawingOffice.mdb", based on two parameters in the knowledge base, PROJECT$ and MODNO$. The relation will be as follows:

A$ = QUERY$(TEXTITEM$(1), PROJECT$, MODNO$)

with in the data slot of the relations (note: we use "|" characters around the text item):

TEXTITEM1=
|@TYPE:ACCESS 
DRIVER=Microsoft Access Driver (*.mdb);DBQ=\\Ma013srv\MVR\Access\DrawingOffice.mdb 
admin 
drawings 
SELECT tbldrawing.drawingno,tblmodel.model,tbltitel.titel,tbldrawing.subject FROM ((tbldrawing INNER JOIN tblmodel ON tbldrawing.modelid=tblmodel.modelid) INNER JOIN tbltitel ON tbldrawing.titelid=tbltitel.titelid) WHERE ((tbldrawing.project=~PROJECT$ ) AND (tblmodel.model='~MODNO$ ')) ORDER BY tbldrawing.drawingno", Project_Nr, Model)|

The places where 

~PROJECT$

 and 

~MODNO$

 are defined will be replaced with the values of 

PROJECT$

 and 

MODNO$

 (see also TEXTITEM$() and TEMPLATE$()). Furthermore please realise that the total script may only cover 5 lines of code:


Line 1: Type of query (Access): 

@TYPE:ACCESS

 


Line 2: Call for the program (Access) and the Filename

DRIVER=Microsoft Access Driver (*.mdb);DBQ=\\Ma013srv\MVR\Access\DrawingOffice.mdb

 


Line 3: User name

admin

Line 4: Password

drawings

 


Line 5: Query script

SELECT tbldrawing.drawingno,tblmodel.model,tbltitel.titel,tbldrawing.subject FROM ((tbldrawing INNER JOIN tblmodel ON tbldrawing.modelid=tblmodel.modelid) INNER JOIN tbltitel ON tbldrawing.titelid=tbltitel.titelid) WHERE ((tbldrawing.project=~PROJECT$ ) AND (tblmodel.model='~MODNO$ ')) ORDER BY tbldrawing.drawingno", Project_Nr, Model)

 


In other words, the last line (the query script) should be one sentence, without any CRLF's. 


 

Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview


  • No labels