PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → SQL Syntax - Returning A Value
SQL Syntax - Returning A Value
Débuté par André Labuschagné, 11 avr. 2018 01:51 - 8 réponses
Posté le 11 avril 2018 - 01:51
Hi All

I have a real brain fart moment here. I know I have done this before but cannot locate the code. I am needing to return a value from an SQL statement, for example, count or max and so on. What is the syntax and how to use in WX?

Cheers
André
Posté le 11 avril 2018 - 10:39
Posté le 11 avril 2018 - 10:44
use something like:
QRY is Data Source
sMyQry is string = [
SELECT count(*) total_records FROM your_file
]
IF NOT HExecuteSQLQuery(QRY, hQueryDefault, sMyQry) THEN
Error(HErrorInfo())
END
Hreadfirst(QRY)
info("The number of records are:"+QRY.total_records)
hcanceldeclaration(QRY)
Posté le 12 avril 2018 - 22:24
Sorted - select max from table AS variable

That did the trick

Cheers
André
Posté le 17 avril 2018 - 15:13
Greetings All
I have difficulties in handling a task in Windev Browsing Table Control.
Now, i am trying to build a small application to keep track of daily hours worked by workers of my plantation. I have created two data files for a start. One keeps personal information about each worker such as
Matricule No, Name of worker, Date of Birth, Date Engaged etc. The second Data file keeps track of the daily hours worked (Times Sheet) and has the following items: Date, Matricule No, Hours worked etc.

Now my difficulty is, i have created a browsing table control based on the second Data file on a window which i want to use to enter data into the data file (Times sheet). On this browsing table control, i have included a column (Name) to show the name of the worker from the personal information Data file, after the Matricule no is entered in the browsing table control.

please any help on how to achieve this in windev. I'm relatively new in windev.

Many thanks in anticipation
Posté le 17 avril 2018 - 16:16
Why didn't you start a new thread?
Posté le 17 avril 2018 - 16:42
Sorry for . I have re-posted on a new thread.
Posté le 27 avril 2018 - 13:43
Use queries
Posté le 28 avril 2018 - 20:53
//Look up the record with the Matricule no ( place key on this )
If hreadseekfirst(file,fileID,Matricule no) then
tablemodifyline( tablewithhours,-1,Matricule no, columname(file.nameperson), other colums)

place the lookoup code in the table on the "after change event" then you can enter the code and then the modifyline can add the restinthe line.

Personally I think it is better to make an edit field for entering the" Matricule no" and then use tableaddline() to fill the rows. Indeed you can use a querie as well

regards
Allard