ruchi.verma
7th July 2008, 14:48
is cross company delete possible if the table definitions are not same...
can switch to company be used for the same...
:confused:

NPRao
7th July 2008, 20:12
can switch to company be used for the same...
No. Refer to - switch.to.company() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_company_operations_switch_to_company)

ruchi.verma
8th July 2008, 08:56
i have one more question n that is whether by performing switch to company a record from a table can be deleted or not???

kbabu1
8th July 2008, 12:28
use ._compnr = <company number > in the select where clause while delete/update record programatically.

eg:

db.retry.point()

select tcibd001.*
from tcibd001 for update
where tcibd001._index1={i.item}
and tcibd001._compnr=100
selectdo
...
if dal.destroy()/dal.update() = 0 then
commit.transaction()
else
abort.transaction()
endif
...
endselect

ruchi.verma
9th July 2008, 08:48
okay so cross company query allows u to update and delete ... but does it allow u to perform the same operations(update/delete) wen the table definitions are different in different companies ???

kbabu1
9th July 2008, 10:25
It should not be a problem if all the fields that u r selecting for update (or delete) exists in both the companies.

Note: all the fields (including indices) mentioned in the SQL clauses(select clause, where clause, etc.,) must exist in both the companies.

ruchi.verma
21st July 2008, 14:05
hi
can u plz illustrate the same using n example.
as i m trying to do a similar thing but unsuccessful.

cyprus
21st July 2008, 15:47
HI Ruchi,

Jus wanted to confirm, r u saying diferent table definitions for different companies? I dont think that would be possible...
For a table, definition remains the same across the companies ...
Could you plz clarify your question ...

ruchi.verma
21st July 2008, 16:07
i have two seperate queries:
1) i want to delete a record from a table existing in different company having same table definition.
2) i want to delete a record from a table existing in different company having different table definition.

cyprus
22nd July 2008, 14:33
i have two seperate queries:
1) i want to delete a record from a table existing in different company having same table definition.

If the table definition are same across companies means companies are attached to same package combination. In this case, you can simply delete the record across comapnies by using <tablename>._compnr in your select query , e.g., As given by kbabu1 in earlier thread :


db.retry.point()

select tcibd001.*
from tcibd001 for update
where tcibd001._index1={i.item}
and tcibd001._compnr=100
selectdo
...
if dal.destroy()/dal.update() = 0 then
commit.transaction()
else
abort.transaction()
endif
...
endselect


2) i want to delete a record from a table existing in different company having different table definition.

If table definition are different for different companies means the companies are attached to different package combinations. In this case you can still delete the records in the table using the above code provided the fields which you have specified in the select query should be present in all the table definitions, or if u r using index to select the record, then index field shuld be same in all companies..

ruchi.verma
24th July 2008, 09:44
hi...

Thanks for the reply Cyprus...
DAL functions are indeed a good option and seems that workin with them wud be reallly easy. But i have realized that they are only compatible with BAAN 5...

since i am working on BAAN 4 i am not able to utilize them...

do you have any other option other than DAL functions.

cyprus
25th July 2008, 08:28
Hi Ruchi,

DAL functions are available from BaaN 5 onwards, but if you are using BaaN 4, you can simply use db.update(<tablename>, db.retry) function...


Cheers ...

ruchi.verma
25th July 2008, 09:23
Thnx Cyprus ...