juvenile
3rd September 2004, 14:43
Hi
In one session i need to delete all the entries in one table and insert frresh records.For this am deleting one by one record.do we have any command to delete entirely at a time like TRUNCATE in Oracle.
Thanks in advance
rgds
juvenile
SriksAdi
3rd September 2004, 14:48
Hi,
You can try out db.clear.table().
Syntax
long db.clear.table( long table_id [, long flag [, long comp_nr]] )
Description
This deletes all data from a specified table. Reference counters are automatically updated.
By default, all deleted records are saved in rollback segments. Consequently, using this function to clear a large table can result in reduced performance and, in some cases, can cause overflow of the internal rollback segments.
Arguments
table_id The table ID, as returned by db.bind().
flag Use this optional argument to indicate whether the delete operation must be performed as a single transaction or as multiple transactions. The possible values are:
0 WITH.ROLLBACK The table is cleared in a single transaction. All records are saved in rollback segments. This is the default option.
1 NO.ROLLBACK The table is cleared in one or more transactions, depending on the number of records in the table. Each transaction is automatically committed after 20 records have been deleted. The number of records deleted in the final transaction can be 20 or less; this depends on how many records remain to be deleted. When you use this option, transactions are small and records are not saved in rollback segments.When you use this option, you must place db.clear.table() at the start of the transaction.
comp_nr This optional argument specifies a company number for the table. The default company is the company of the user.
Return values
0 success
<>0 error
toolswizard
7th September 2004, 15:24
Here is something close to the standard that Baan uses in it's standard program and we have adopted as a standard:
fcmp = read.physical.company("tdinv150")
commit.transaction()
ret = db.drop.table(ttdinv150, DB.IGNORE.ALL.REFS, fcmp)
if ret then
if db.clear.table(ttdinv150, no.rollback, fcmp) then
execute(abort.program)
endif
else
db.create.table(ttdinv150, fcmp)
endif
commit.transaction()
function long read.physical.company(string tabel(8))
{
static long fcmp
string module(5)
static long cur.comp
module=tabel(1;5)
fcmp = get.compnr()
cur.comp = fcmp
select ttaad420.fcmp:fcmp
from ttaad420
where (ttaad420._index2 = {:cur.comp, ttaad.tabg.specified,:tabel}
and ttaad420._compnr = 0)
or
(ttaad420._index2 = {:cur.comp, ttaad.tabg.all.in.modu, :module}
and ttaad420._compnr = 0)
or
(ttaad420._index2 = {:cur.comp, ttaad.tabg.all, ""}
and ttaad420._compnr = 0)
selectdo
return(fcmp)
endselect
return(fcmp)
}