berthe
8th March 2004, 16:16
Hi everyone,

I'm writing a script that reads date from the table whwmd215 for all companies.
When I try to read a table that doesn’t exist in the considered company, I get the Error 506 BW message window and the script stops. How can I make the script check the existance of the table before reading it?

I tried the following code, but then I receive the error 203
db.retry.point()
db.create.table(twhwmd215, comp)
commit.transaction()

Any sugestions ?

Thanks in advance!
Berthe

Hitesh Shah
8th March 2004, 16:27
Errno 203 means DDL statements are not permitted within an active transaction. It should work.

en@frrom
8th March 2004, 16:27
Hi,

You can simply use whwmd215._compnr.

For instance, if you only want to know if a table exists, just write:

domain tcbool table.exists

select whwmd215.*
from whwmd215
where whwmd215._compnr = :company
as set with 1 rows
selectdo
table.exists = true
selectempty
table.exists = false
endselect

Good luck!

En.

berthe
8th March 2004, 16:40
Hi,

only "db.create.table" doesn't work. I even tried a new empty script with only this function, It logged off and on and still I receive error 203.

The second suggestion (selectempty) doesn't work neighter. If the table doesn't exist, I can not use the select-statement. I can only use this code if the table exists, but is empty.

Thanks anyway!
Berthe

NPRao
8th March 2004, 19:24
Berthe,

Refer to the link for more info -

db.drop.table() (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=802&highlight=dml)

You have to issue a - commit.transaction() before the db.create.table().

The second suggestion (selectempty) doesn't work neighter. If the table doesn't exist, I can not use the select-statement. I can only use this code if the table exists, but is empty.
You can change your code to look like-

domain tcbool table.exists
error.bypass = 1
select whwmd215.*
from whwmd215
where whwmd215._compnr = :company
as set with 1 rows
selectdo
table.exists = true
selecterror
table.exists = false
endselect

berthe
9th March 2004, 09:42
I used the selecterror and it works just fine!

Thanks!
Berthe