Build-in Querybuilder

Build-in Querybuilder

Postby Marc Vanzegbroeck » Tue Aug 07, 2018 6:31 am

Hi,

I want to implement a query-builder in an application.
Is there an easy way to verify the correct syntax before running the query?
The users of the application are engineers, so they know how to make queries.

I want that they enter something like :
NAME = 'FI123' OR PTDESC like '%B701%'
They don't have to enter the table-name. It's one that is selected, so i can already enter the beginning op the query....
I just add the antered text after the 'WHERE' clause

It will be also nice that the is maybe an autocomplete, or a selection-list of the available field-names
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Build-in Querybuilder

Postby Antonio Linares » Tue Aug 07, 2018 7:18 am

Marc,

Please review FWH function FWExpBuilder( cExp, oRs, nClrTxt, nClrBack )

This function is used from FWH\samples\fivedbu.prg so you can test it

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41324
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Build-in Querybuilder

Postby Marc Vanzegbroeck » Tue Aug 07, 2018 7:31 am

Thank you Antonio,

That's a very good start.
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Build-in Querybuilder

Postby Marc Vanzegbroeck » Fri Aug 17, 2018 3:17 pm

Antonio,

I have tested it, but I have a problem.
I'm using a recordset.

I first call FWExpBuilder()

Then I call FWCheckExpression() to see if the result is ok, but I'm always get the error 'Variable does not exist' This is the fieldname of the oRs.
I tested it with FWH64 May 2016 (FWH 6.04 Revd Build-3)
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Build-in Querybuilder

Postby Antonio Linares » Fri Aug 17, 2018 9:11 pm

Please copy here the expression that you build

In case that you are using a local variable, turn it into a public one
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41324
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Build-in Querybuilder

Postby Marc Vanzegbroeck » Sat Aug 18, 2018 8:44 am

Here is a little test:
adoHaalPointselRecordset() returns the recordset.

Code: Select all  Expand view
FUNCTION tpsquery()
local cfilter :=  ''
oRsQuery = adoHaalPointselRecordset()
FWExpBuilder( @cFilter, oRsQuery )
IF FWCheckExpression (cfilter)
ELSE
    msgalert('Filter invalid')
ENDIF
return nil
 


This is the query:
Image

Here the message:
Image
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Build-in Querybuilder

Postby Marc Vanzegbroeck » Sun Aug 19, 2018 2:03 pm

I found the mysql_error() in the mariadb functions to display the last sql-error, but don't know how to display it :cry:
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Build-in Querybuilder

Postby Marc Vanzegbroeck » Sun Aug 19, 2018 2:22 pm

I found it with calling 'SHOW ERRORS' :)
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 20 guests