Page 4 of 10

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 1:34 pm
by sudip
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

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 1:35 pm
by Roberto Lopez
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.

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 1:43 pm
by gfilatov
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:

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 3:37 pm
by Roberto Lopez
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.

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 3:40 pm
by Roberto Lopez
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.

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 4:04 pm
by sudip
Thank you Master Roberto :)
With best regards.
Sudip

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 6:24 pm
by mol
It's out of this discussion - yes, I've changed my avatar, changes are needed sometimes :-)

Re: My First SQLite Project

Posted: Tue Sep 15, 2009 6:26 pm
by mol
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.

Re: My First SQLite Project

Posted: Wed Sep 16, 2009 2:11 am
by luisvasquezcl
hi,
can also use database access. It lets
use the full power of SQL with a database very
friendly and zero installation.
regards,

Re: My First SQLite Project

Posted: Wed Sep 16, 2009 5:25 am
by mol
Is it possible to get table sorted with native characters?