Welcome! Log In Create A New Profile

Advanced

Connection, SQL and HFSQ Classic

Posted by jacek 
Connection, SQL and HFSQ Classic
June 23, 2021 06:10PM
Hi,

Is it possible to run a SQL statement on a HFSQL Classic tables without creating analysis ?

Thanks in advance for your kind and elaborating answer
/Jacek
Argus
Re: Connection, SQL and HFSQ Classic
June 23, 2021 08:16PM
why would you want to have HF files without analysis in the first place?

Up till now, all the developers refusing to use the analysis have been using their pet DB outside the HF world...

But using HF without analysis is like using shoes without having any legs...
Re: Connection, SQL and HFSQ Classic
June 23, 2021 11:39PM
Re: Connection, SQL and HFSQ Classic
June 23, 2021 11:50PM
Hi ,
Thanks Argus.
I see, I should have explained myself in more detail.

My customers have various preferences concerning a DB, they want to maintain.
I had a dream that I shall be able to use HExecuteSQLQuery() with a connection. Same desktop application but different connection in case of each customer (defined in her/his INI file). Suddenly, surprise, it works with most DBs but the one native to Windev.

The SQL I have to use is complicated enough that I couldn't (i.e. didn't know how to) make it work in Query Editor. Still seems to me that using SQL is faster and more flexible, especially as HExecuteSQLQuery() and other H* functions work just fine . This is the main reason I have dropped using analysis altogether.

I don't have a Clarion background and the intuitions behind Windev have baffled me several times. The surprise here was the most recent one.
I understand that there could be a better, a more Windev-like design...
A push in a right direction, please...

And the H* functions and the SQL* functions will not work with HFSQL Classic tables, correct ?

All the best
/Jacek
Re: Connection, SQL and HFSQ Classic
June 23, 2021 11:57PM
Hi Dennis,

Thanks a lot.
Will try it tomorrow.

:-)
/Jacek
Argus
Re: Connection, SQL and HFSQ Classic
June 24, 2021 03:10PM
Your problem is going to come from SQL fairly complicated...

This is how I would do it:

- Use an analysis ALWAYS
- In it declare the files as HF classic ALWAYS
- Make ALL QUERIES in the query editor. yes you will not be able to do everything there, so use SIMPLER queries and process the result by code in your program for the more complex stuff. This has several advantages:
1. automatic completion in your code, as the query is known
2. Simpler query easier to debug if data problem
3. The complex part is in code, therefore you can DEBUG IT easily, maintain it and modify it
4. Because part of the process is done on the client, instead of having, the solution is much more scalable, as 1001 processors are used to do the jog instead of 1 when you have 1000 users...
5. the query editor will AUTOMATICALLY translate in the proper SQL variant when you do the next step
- When a customer want another type of DB, just do hchangeconnexion in your code, and EVERYTHING ABOVE still works without any change.
This can be done simply by reading from an ini file, which means NO CHANGE IN YOUR PROGRAM for ALL your cases.
pao
Re: Connection, SQL and HFSQ Classic
June 24, 2021 04:24PM
Yes, it is to do SQL instructions without the analisys.
Check hdeclareexternal in the help to define and use the flies
[doc.windev.com]

Be carefull the files can stay single-user mode, if you need to have other users working at the same time witth the same files use hmode
[doc.windev.com]

You can use HF classic files uisng the analisys and change the connection when you need to use another copy of the files, we use it a lot.
You can use HREAD* functions an you can use HEXECUTESQL* if you need it with HF classic and analisys.

HDescribeConnection("MYCONN","","","C:\MY_BD_1","",hAccessHF7,hOReadWrite,"")
HOpenConnection("MYCONN")
HChangeConnection("*","MYCONN")

Regards

Paulo Oliveira



Edited 1 time(s). Last edit at 06/24/2021 04:32PM by pao.
Re: Connection, SQL and HFSQ Classic
June 25, 2021 07:43AM
Thanks a lot Argus,
I can see your point now.
All the best
/Jacek
Re: Connection, SQL and HFSQ Classic
June 25, 2021 07:52AM
Hi Paulo,
Thanks a lot for the links and examples.
But still I don't like it. I don't fancy special cases. smiling smiley
All the best
/Jacek
Re: Connection, SQL and HFSQ Classic
June 27, 2021 12:19PM
Greeting

I personally use multiple connections in my application: 1-Connection HF SQL C / S 2-Connection HF Classic (local) 3-Connection MySQL
There are all these tables in my Analysis and I perform all operations on my tables using SQL queries because they do the job the fastest and most securely, especially if it is a remote server

[infosonline.net]
Argus
Re: Connection, SQL and HFSQ Classic
June 28, 2021 12:10AM
>> I perform all operations on my tables using SQL queries because they do the job the fastest and most securely, especially if it is a remote server

I had many cases where a few hreadxxxx instructions did the job WAY faster than any query could...

A very simple example: a table linked directly to a file wil give control to the user WAY faster than if the table is linked to a query...

So no, using ANYTHING ALL THE TIME is not the solution.
Re: Connection, SQL and HFSQ Classic
June 29, 2021 01:52PM
Hi,
Thanks very much indeed for your suggestions.
Finally I went for Jerko (infos) solution. In my case it is not the speed (chapeau bas Argus) but the flexibility that is more important.
All the best
/Jacek
PS. The discussion helped me to put quite a few things straight. Thanks again
Re: Connection, SQL and HFSQ Classic
July 23, 2021 10:40AM
Argus

" - In it declare the files as HF classic ALWAYS "

Why do you suggest classic files ??

If the application is built to run on HF C / S. Then why did PC Soft develop HF C / S files?

What are the advantages of your claim?

[infosonline.net]



Edited 1 time(s). Last edit at 07/23/2021 10:46AM by infos.
Renko vd molen
Re: Connection, SQL and HFSQ Classic
July 26, 2021 10:57AM
always user analysis .So you have intellicense in your code . At least onthe files.

Complex queries: Make the query in for instance Ms sqlserver studion or if you have the bugs for it use a tool fot this

windev++. use sqlexecute
This will run every possible query for you Use folowing syntax

something is string = [

here comes your query ==>where something = '%1' and somenthing = '%2'


]

completesql = stringbuild(.something, firstparma, secondparam)

sqlexe(completesql,"qeryname")

with this you can runthe debugger and stop it onthe complete generated sql and you can compy past it in yuour db tool to see if sql is OK


regards
Renko
Argus
Re: Connection, SQL and HFSQ Classic
July 27, 2021 04:21PM
> Why do you suggest classic files ??
>
> If the application is built to run on HF C / S.
> Then why did PC Soft develop HF C / S files?


I didn't say to USE classic all the time, I said to DECLARE them as classic, then CHANGE to whatever you need doing a hchangeconnexion.
And yes, classic should be use only for local/mono user cases (which in replication, is always the case)

So, the advantages:
- by DECLARING the files as classic, you do not declare a connexion to a DB in the analysis, and therefore do not have problem when that connexion is not reachable when deployed at your customer.
- if you are using wxreplication, as I do, your local classic files do not need any special install (no hfcs install/configuration to do)... that means that you install the soft, run it (do your enrollment for the replication) and you are set, without any need of technical intervention
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: