SQL Express - begin

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

SQL Express - begin

#1 Post by Victorio »

Hi,
I am beginner in SQL, and want understand, how it works. Because I modify some example with use SQL express library.
Now I have running SQL Server 2008, and existing database MDF.
I know how open database, browse it and create cursor by SELECT..., get some data from it by :FieldGet

Because I want combine DBF database with MDF, it means if listing in DBF database in one field I want see data
gained from MDF database.

I want create function that gain data from mdf while listing in database, for example want color some rows by value from MDF

I created this :

cStatement := 'SELECT KU_ID,CLV,PCS,ZNA,CPS,ROL FROM LIS_PLOMBA,LIS_PLOMBA_HIS,LIS_KNIHY WHERE (LIS_PLOMBA.PLO_ID = LIS_PLOMBA_HIS.PLO_ID) AND (LIS_PLOMBA.LIS_ID = LIS_KNIHY.LIS_ID) AND (LIS_PLOMBA.CLV='+cislolv+') AND (LIS_PLOMBA.KU_ID='+cisloku+') AND (LIS_KNIHY.ZNA=1 OR LIS_KNIHY.ZNA=2 OR LIS_KNIHY.ZNA=3) AND (LIS_KNIHY.STL=1 OR LIS_KNIHY.STL=4 OR LIS_KNIHY.STL=5) AND (LIS_PLOMBA.PLM=2 OR LIS_PLOMBA.PLM=3) AND (LIS_PLOMBA.PLS=1) AND (LIS_KNIHY.LTY=1)'

oCursor := CreateSQLCursor( oConnection, 2, cStatement)
nsuccess:=oCursor:execute()

In this moment, I do not want browsing MDF database, only quick get data from it and put it to DBF file, or show when browsing DBF database.

Many thanks for any advice.



if nsuccess>=1
spis_cps:=oCursor:FieldGet("CPS")
spis_rok:=oCursor:FieldGet("ROL")
spis_pcs:=oCursor:FieldGet("PCS")
return spis_spc+spis_rok+spis_pcs
endif

But it was slow, If run this in cycle 100times, wait several seconds.

I mean, I cannot create cursor many times, every row, but save data from one time created cursor, and then process it from array

Is this a little right way ?

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: SQL Express - begin

#2 Post by Victorio »

after some study, :geek: I examine this

Example
oCursor := SQLSelect():new("SELECT * FROM Products ORDER BY Type,Make,Model", oMyConn)
oCursor:Execute()
oCursor:Seek( "Camera" ) // single value/field
oCursor:Seek( {"Camera","Contax","RTS"} ) // multiple values/fields

and it is I mean better way and more faster.

little of it I begin to understand...

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SQL Express - begin

#3 Post by rdonnay »

I am doing all my SQL stuff either with ADSDBE or ODBCDBE.

When using SQLServer, I use ODBCDBE because then I can apply SQL queries to a work area.
The eXpress train is coming - and it has more cars.

Post Reply