Temporary table
Moderator: Rathinagiri
Temporary table
Hi all,
I am now trying to create reports like I did in visual fox.
to create in fox select * from table into cursor ...... I now have a temp file.
What I am doing in hmg3.2 is in samples,miscellaneous,temporary.table
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 .............. EG: or append from table for fieldname = 'something'
curItem->itemcd := "CD"
curItem->itemnm := "Compact Disc"
curItem->rate := 10.00
unlock
This all working fine but I wonder if the temp table is in memory as I can not find it
on my computer. Also if I create an index with same name it also is not visible.
My main concern is when i release the window is the table and index erased.
I could create a real table and index and erase later but more programing involved.
Thanks in advance ............ Franco
I am now trying to create reports like I did in visual fox.
to create in fox select * from table into cursor ...... I now have a temp file.
What I am doing in hmg3.2 is in samples,miscellaneous,temporary.table
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 .............. EG: or append from table for fieldname = 'something'
curItem->itemcd := "CD"
curItem->itemnm := "Compact Disc"
curItem->rate := 10.00
unlock
This all working fine but I wonder if the temp table is in memory as I can not find it
on my computer. Also if I create an index with same name it also is not visible.
My main concern is when i release the window is the table and index erased.
I could create a real table and index and erase later but more programing involved.
Thanks in advance ............ Franco
All The Best,
Franco
Canada
Franco
Canada
-
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: temporary table
Hola Franco,
No te preocupes por si ocupa memoria o no, HMG hace que la memoria sea optimizada!, solo hay problemas de memoria si tienes una tarea que no termina, por ejemplo un while!!!. Por lo demás no te preocupes!!!
Saludos
No te preocupes por si ocupa memoria o no, HMG hace que la memoria sea optimizada!, solo hay problemas de memoria si tienes una tarea que no termina, por ejemplo un while!!!. Por lo demás no te preocupes!!!
Saludos
Re: temporary table
sorry Javier, I have forgotten how to convert to english, so I cannot read your reply
Franco
Franco
All The Best,
Franco
Canada
Franco
Canada
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
temporary table
Sorry Franco, but I am not understanding what you are trying to say. If you use hb_dbcreatetemp you will certainly create a temp file into the memory, not at disk. Why do you what to fin at your computer ? For what ?franco wrote:I now have a temp file.
What I am doing in hmg3.2 is in samples,miscellaneous,temporary.table
..//..
...all working fine but I wonder if the temp table is in memory as I can not find it
on my computer
You can create index but with this TEMP file into the MEMORY will also not be saved at disk. Same case that dbf TEMP when is used hb_dbcreatetemp.franco wrote:Also if I create an index with same name it also is not visible
Table and index will not be deleted because it doesn't exist as files saved at disk, only in the memory. But for what do you need these files saved ?franco wrote:My main concern is when i release the window is the table and index erased.
Not much work. Change hb_dbcreatetemp for hb_dbcreatefranco wrote:I could create a real table and index and erase later but more programing involved.
Franco, you posted at spanish section. (Topic is being chabge to the right place)franco wrote:sorry Javier, I have forgotten how to convert to english, so I cannot read your reply
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
temporary table
Franco, if you want to create files saved at disk, you can do this:
Using COPY TO you will get same phisically in file.
Code: Select all
#include <hmg.ch>
* Temporary Table Test by Grigory Filatov
* Slightly modified by Roberto Lopez
Function Main
CreateTemp()
define window winMain ;
at 0, 0 ;
width 640 height 480 main ;
title "Temporary Table"
DEFINE GRID brwTemp
COL 0
ROW 0
WIDTH 600
HEIGHT 340
HEADERS {"Item Code", "Item Description", "Rate"}
WIDTHS {125, 300, 100}
ROWSOURCE "curItem"
COLUMNFIELDS {"itemcd", "itemnm", "rate"}
END GRID
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 Disc"
curItem->rate := 10.00
unlock
append blank
curItem->itemcd := "DVD"
curItem->itemnm := "Digital Versatile Disc"
curItem->rate := 20.00
unlock
append blank
curItem->itemcd := "BD"
curItem->itemnm := "Blu-ray Disc"
curItem->rate := 30.00
unlock
COPY TO "TEST.DBF" // copying phisically the dbf in the memory to a file
index on itemnm to TempNTX
COPY TO "TEST.DBF" // copying already ordered by the index key
Seek "Digital Versatile Disc"
If Found()
MsgInfo(str(Recno())+" - "+itemcd)
Endif
return nil
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
temporary table
Hi Francofranco wrote:I wonder if the temp table is in memory as I can not find it
on my computer. Also if I create an index with same name it also is not visible.
My main concern is when i release the window is the table and index erased.
I could create a real table and index and erase later but more programing involved.
Here a little quote
I hope this will give you an ideaHarbour\Changelog : wrote: 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.
If you prefer doing everything manually, the TempFile() function of Harbour will be useful.
Happy HMG'ing
Last edited by esgici on Wed Sep 03, 2014 4:48 pm, edited 1 time in total.
Viva INTERNATIONAL HMG
-
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: Temporary table
-1franco wrote:sorry Javier, I have forgotten how to convert to english, so I cannot read your reply
Re: Temporary table
Thanks to all,
I did not know I posted to Spanish
This whole post was to make sure temp files disappear as I use them a lot in making reports
and did not want them building up on hard drive.
Thanks again and all working well. .......... Franco
I did not know I posted to Spanish
This whole post was to make sure temp files disappear as I use them a lot in making reports
and did not want them building up on hard drive.
Thanks again and all working well. .......... Franco
All The Best,
Franco
Canada
Franco
Canada
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Temporary table
Hi All
Another fuzzy point is : DBCreate() is OK for Clipper and Harbour, but I didn't found hb_dbcreate() function;
would you express me which library required for use it ?
Happy HMG'ing
Does anyone would clarify : "Which RDDs ?", and "when ?"Above Harbour Changelog quote wrote:...Some RDDs may also do not create temporary files but keep
everything in memory if they decide it's more efficient.
Another fuzzy point is : DBCreate() is OK for Clipper and Harbour, but I didn't found hb_dbcreate() function;
would you express me which library required for use it ?
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: Temporary table
esgici,
I am not sure if this is dll but I must start with #include "hfcl.ch" or the hb_dbcreatetemp()
does not work
I am still having trouble with print grid from a table.
It does not make sense to create a temp table with some fields of a real table, then crate an array
to use print grid. maybe you can help with this.
or how do I just create an array with certain fields of a real table then sort on one of the
fields. I know this is easy but can not find example.
Thanks ............. Franco
I am not sure if this is dll but I must start with #include "hfcl.ch" or the hb_dbcreatetemp()
does not work
I am still having trouble with print grid from a table.
It does not make sense to create a temp table with some fields of a real table, then crate an array
to use print grid. maybe you can help with this.
or how do I just create an array with certain fields of a real table then sort on one of the
fields. I know this is easy but can not find example.
Thanks ............. Franco
All The Best,
Franco
Canada
Franco
Canada