My First SQLite Project

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Re: My First SQLite Project

Post by sudip » Tue Sep 15, 2009 1:34 pm

Hello Master Roberto,

I found that function in \Harbour\source\rdd\dbcmd.c and in \Harbour\include\hbextern.ch files. I heard about this function from G. Filatov.

I also have a demo which run on HMG Extended.
#include <minigui.ch>

Function Main
SET DELETED ON

define window winMain ;
at 0, 0 ;
width 640 height 400 main ;
title "Temporary Table" ;
on init CreateTemp()

DEFINE BROWSE brwTemp
COL 0
ROW 0
WIDTH 600
HEIGHT 340
HEADERS {"Item Code", "Item Description", "Rate"}
WIDTHS {125, 300, 100}
WORKAREA curItem
FIELDS {"curitem->itemcd", "curitem->itemnm", "curItem->rate"}
ALLOWEDIT .T.
INPLACEEDIT .T.
ALLOWAPPEND .T.
ALLOWDELETE .T.
LOCK .T.
JUSTIFY {0, 0, 1}
END BROWSE

@ 350, 0 label lblShow value "Alt-A: Add, Dbl-Click: Modify, Del: Delete" AUTOSIZE

end window

winMain.center
winMain.activate

Return



function CreateTemp()
local aDbf := {}
aadd(adbf, {"itemcd", "c", 10, 0})
aadd(adbf, {"itemnm", "c", 40, 0})
aadd(adbf, {"rate", "n", 8, 2})

if !hb_dbcreatetemp("curItem", adbf)
msgbox("Cannot create temporary table: Item")
RELEASE WINDOW ALL
return nil
endif

if select("curItem") = 0
use curItem new
endif
select curItem
append blank
curItem->itemcd := "CD"
curItem->itemnm := "Compact Disck"
curItem->rate := 10.00
unlock

return nil
Please don't misunderstand me. I don't want to compare with 2 versions. I am telling about this because temporary table is really useful for programmers (especially those came from VFP :))

Please correct me if I am wrong.

With best regards.

Sudip
Last edited by sudip on Tue Sep 15, 2009 1:41 pm, edited 2 times in total.
With best regards,
Sudip

User avatar
Roberto Lopez
HMG Founder
Posts: 3979
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 167 times

Post by Roberto Lopez » Tue Sep 15, 2009 1:35 pm

mol wrote:Hi Sudip!
Fine project. I've never wrote any application with SQL, but, I think that will be future.

What about refreshing table after changing/adding new record?
Whether it is necessary to call GET_DATA function after every change?
What about refreshing in multiuser environment?
Recurring data downloads after defined period?
You should think SQL as web pages.

You must do a request to the server, then, the server sends to you a recordset.

If you want to know if the recordset has changed, you must 'requery' (do the query again).

The nice thing is that you should not care about indexes, since 'order by' clause in SELECT command, care about it.

Things like duplicate keys are automatically handled by the server too.

You only need four commands for the almost all things:

- SELECT
- UPDATE
- DELETE
- INSERT

Select, returns a recordset that can be 'narrowed' via WHERE clause (quite similar to FOR clause in xBase).

Multiuser is automatically handled too. If you want to lock a table you can do it too.

Some other nice things, are transactions and security.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
gfilatov
Posts: 656
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 24 times
Been thanked: 227 times
Contact:

Post by gfilatov » Tue Sep 15, 2009 1:43 pm

Roberto Lopez wrote:...
I don't knew that function.

I'll try to research a little...
Hi Roberto,

Take a look for the following record in the Harbour changelog:
2009-02-16 17:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/dbinfo.ch
+ added DBI_ISTEMPORARY

* harbour/include/hbapirdd.h
* harbour/source/rdd/wafunc.c
+ added hb_rddCreateTableTemp() C function to create temporary
table which are automatically deleted on close. All indexes and
memo files for such tables are also in temporary files and
automatically deleted on close. Please remember that Harbour uses
OS functions to create temporary files so it's installation dependent
how much disk space is available for them. Some RDDs may also do
not create temporary files but keep everything in memory if they
decide it's more efficient.

* harbour/source/rdd/dbcmd.c
+ added .prg function to create temporary files:
hb_dbCreateTemp( <cAlias>, <aStruct>, <cRDD>, ;
<cCodePage>, <nConnection> ) -> <lSuccess>
Not all RDDs have to support it. It's verified by support for
DBI_ISTEMPORARY dbInfo() action.

* harbour/include/hbrdddbf.h
* harbour/include/hbrddnsx.h
* harbour/include/hbrddcdx.h
* harbour/include/hbrddntx.h
* harbour/source/rdd/dbf1.c
* harbour/source/rdd/dbffpt/dbffpt1.c
* harbour/source/rdd/dbfntx/dbfntx1.c
* harbour/source/rdd/dbfnsx/dbfnsx1.c
* harbour/source/rdd/dbfcdx/dbfcdx1.c
+ added support for temporary tables in native RDDs.

Most of above modifications were done by Viktor Szakats.
:idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
Roberto Lopez
HMG Founder
Posts: 3979
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 167 times

Post by Roberto Lopez » Tue Sep 15, 2009 3:37 pm

gfilatov wrote: Hi Roberto,

Take a look for the following record in the Harbour changelog:
<...>
Thanks!

I'll take a look at that.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Roberto Lopez
HMG Founder
Posts: 3979
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 167 times

Post by Roberto Lopez » Tue Sep 15, 2009 3:40 pm

sudip wrote: Please don't misunderstand me. I don't want to compare with 2 versions. I am telling about this because temporary table is really useful for programmers (especially those came from VFP :))

Please correct me if I am wrong.

With best regards.

Sudip
No problem!

You are absolutely right.

I'm waiting to final Harbour 2.0 release to incorporate to HMG distribution.

Despite that, I'll start testing it ASAP.


Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 1 time

Post by sudip » Tue Sep 15, 2009 4:04 pm

Thank you Master Roberto :)
With best regards.
Sudip
With best regards,
Sudip

User avatar
mol
Posts: 3214
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 222 times
Been thanked: 123 times
Contact:

Post by mol » Tue Sep 15, 2009 6:24 pm

It's out of this discussion - yes, I've changed my avatar, changes are needed sometimes :-)

User avatar
mol
Posts: 3214
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 222 times
Been thanked: 123 times
Contact:

Post by mol » Tue Sep 15, 2009 6:26 pm

I'm waiting for more advanced project with sqlite...
I will rebuild one of my application to work with SQL...
But now, I'm busy with one huge project.

User avatar
luisvasquezcl
Posts: 1140
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 14 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Wed Sep 16, 2009 2:11 am

hi,
can also use database access. It lets
use the full power of SQL with a database very
friendly and zero installation.
regards,

User avatar
mol
Posts: 3214
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 222 times
Been thanked: 123 times
Contact:

Post by mol » Wed Sep 16, 2009 5:25 am

Is it possible to get table sorted with native characters?

Post Reply