Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[xHarbour] SQLRDD problems.

Status
Not open for further replies.

mathmax

Programmer
Apr 21, 2006
22
FR
Hello,

I currently try to use xharbour in order to run my clipper programs on
a SQL Server database.
Many points that surprised me :

- A program that just displays all the records of a table is twice
faster running on a .dbf file than running on a SQL Server database.
Is it normal ?

- What is a lot more surprising is that the same program compiled with
the original clipper v 5.2 compiler is about 25 times faster than
compiled with the xHarbour compiler ! Why such a difference ??

- Is there a possibility to change the name of the tables in the sql
database without changing the use instructions in the clipper
program ?
For instance, having this instruction :
use c:\aFolder\Order.dbf VIA "sqlrdd"
should the name of the sql table necessarily be named :
"_aFolder_Order_DBF" ? Or is there a way to remove "_DBF" for
example ?

- It seems that xHarbour doesn't support exclusive file opening and
record locking. I mean exclusive instructions and FLOCK(), RLOCK()
functions have no effects. Is there something more to do to have
exclusive access on a table/record ?

Thank you in advance for any help, clarifications or suggestions.

mathmax
 
I think you should study on the differences of relational database models (SQL) compared to simple table based database models (DBF). You seem to be comparing apples to pears here. SQL is transaction & resultset based, while DBF is record based. Retrieving SQL records 1 by 1 is _very_ inefficient, doing a "SELECT * FROM Table", and displaying rows from the resultset is much more efficient. (xHarbour even supports the "FOR EACH" statement...)

Performance of my xHarbour compiled Clipper apps is 2 to 5 times better, when compiled with xHarbour. Depends on the type of operations you do. If only the above mentioned database actions are measured and using SQLRDD, speed could be problematic, but bare metal loops en calculations can be much faster.

On the USE statement, check out the ALIAS clause, it allows you to name the working area any way you need (within naming restrictions ofcourse)

(Btw, I haven't used SQLRDD driver myself, only the free Mediator from OTC.pl, but it has similar 'issues')

HTH
TonHu
 
Thank you for your explanations, ThonHu. In fact it is the display that is a lot slower with xHarbour.
Here was my test program :

#include "sqlrdd.ch"
procedure harb()
Connect() // function in C:\xHB\samples\sqlrdd\connect.prg
use q:\test.dbf VIA "SQLRDD"


debut = seconds()


for i:=1 to 5000
go top
do while !eof()
? valu
skip
enddo
next i


fin = seconds()
? "Execution time: ", trim(str(fin -debut))
return

If I remove the line
? valu
The program is a lot faster and even faster when compiled with xHarbour if it runs on .dbf files.
However it's always a lot slower when running on a sql table (takes about 4 seconds with sql server to 0,02 seconds with .dbf files). Do you think a such difference is due to the fact that many one-result queries are send to the database ?
Or is there an other problem ?
Concerning the display, someone told me that it is a lot slower in xharbour than clipper due to the way clipper works (dos and direct screen memory access) that is forbidden under windows. Do you know if there is a way to improve the speed of display ?

I try adding an alias to the "use" instruction like that :
use q:\MyFolder\orders.dbf alias orders via "sqlrdd"
but it always research a table called "_MyFolder_orders_dbf" whereas I would like it to research a table called "orders"...

An other question: When compiling a .prg file, the compilator throws an error :
"Statement not allowed outside of procedure or function"
So it seems that all code needs to be encapsulated in a procedure or function whereas it is not necessary for the original Clipper 5.2 compilator. I would like to know if there is a way (maybe a compilation option) so that it is not necessary to add a function around my code. I have hundreds of .prg files and would rather prefer to avoid adding function in each of them.

Thanks a lot for your help.

Regards,

mathmax
 
Changing your GT driver to GTWVT or GTWVW could solve some of the slower display issues, especially on WinXP systems.

The ALIAS feature is probably better answered at the xHarbour NG on Google Groups.

The "Statement not allowed..." means that you are compiling with -n option as advised in the xHarbour docs, so your prg doesn't get a 'surrounding' procedure <progname>, which is the default with Clipper. But Clipper does support that same compile-time switch... xHarbour and Clipper -n parameter does not allow executable code to exist outside of a function or procedure, and by not having the <progname> procedure, you are outside of any procedure... Are you calling your <progname> procedure directly? If not you should be able to remove the offending lines, IMHO.
Removing the -n switch should give the Clipper compatible situation you want.

HTH
TonHu
 
Hi

How can I change the Gt driver. Is it something to install ? Is there any url where I can download those drivers ?

Concerning my compilation problem, I've read in the documentation that xBuild Project Builder by default set the –n option. As far as I've understood, the only way to remove this option is to define other options. That's not a problem for me at the moment because I want to compile my program with the /M option, but I would be a serious problem if I wouldn't like to define other options and although remove -n...

However I still have a problem for converting my .rmk file to a .xbp file.
Here is what my .rmk file looks like :

.prg.obj:
clipper $< /M
CODE1.OBJ: CODE1.PRG
CODE2.OBJ: CODE2.PRG
CODE3.OBJ: CODE3.PRG

.prg.obj:
clipper $< /M/N
CODE4.OBJ: CODE4.PRG
CODE5.OBJ: CODE5.PRG

MYAPP.EXE :CODE1.OBJ CODE2.OBJ CODE3.OBJ CODE4.OBJ CODE5.OBJ
BLINKER @MYAPP

As you can see, some .prg files are compiled with /N options and other are compiled without it.
In xBuild Project Builder I cannot find a way to do that... There is a field where we can define some compilation flags but they applied to all the .prg files. Do you have a solution for this problem ?

Thank you for your help.

mathmax
 
Sorry, but I'm using the .org (open source) version of xHarbour (without the support by xHarbour.com) If you have a valid contract with them, they should give you the support for questions like this, as I'm using HBMake for creating and running make scripts. These can be manually modified.

I'd go for having the /n option on all your sources, as that's the default for xHarbour.

Linking in GTWVW or GTWVT (called WVW or WVT in xHarbour.com, AFAIRC) should cause GTWIN (the default GT) to be left out of your exe, but I'm not sure it does. Just try and see.

HTH
TonHu
 
Hi,

I currently try the 30 days trial version of xHarbour, but maybe make scripts of .org version could be used with my version. In any case, I would be interested to know how do that with HBMake.

Sorry, but I'm quite novice and I don't understand what you explain to me about GTWVW or GTWVT. Could you detail me the steps for installing those drivers ?

Thank you.

mathmax.
 
Hm, sorry, but the HBMake tol is not delivered with xHarbour.com. As said before, I'm not using the commercially supported version of xHarbour, so I wouldn't know how to add these mods to the scripts used by the Builder tool of xHarbour.com. Last time I saw it it was very easy to add libs etc. by drag&drop into the right windows, when Builder is open.
There must be some hints or info on how to change the GT driver (helpfile?), it would usually only require to change a lib and optionally add some initialisation.

HTH
TonHu
 
Linking in GTWVW or GTWVT (called WVW or WVT in xHarbour.com, AFAIRC) should cause GTWIN (the default GT) to be left out of your exe, but I'm not sure it does. Just try and see.

I try adding those libraries to the linkage, but the display is still slow. How to check that GTWIN isleft out of my exe ?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top