Hiba_t
27th August 2008, 14:14
Hi all,

I'm writing a program were I run some dynamic sqls. But before I run these queries I need to know if the tables I'm dealing with exist in the current company.

What command can I use? Can someone show me how can I check if a table exists in a company? I mean if the table has been created in a specific company.

Thanks in advance,
Hiba

SergioRuiz
27th August 2008, 14:23
Hello, tou need to use db.bind, db.first and error bypass

long hold.error, table.id

table.id = db.bind("t" & tablename)
hold.error = error.bypass

error.bypass = true

db.first(table.id)

if e = enotable then
message("Error, table doesn´t exist")
endif

error.bypass = hold.error

db.unbind(table.id)

I hope it helps you

Hiba_t
27th August 2008, 15:04
Thanks...

But instead of enotable, it should be enodd.
And after the message it should end. Since unbind command for a table that doesn't exist kicked me out of baan.

SergioRuiz
27th August 2008, 15:40
Yes, db.unbind must be in the else when you check the value of e, sorry.
But, for me in baanIV, enotable works, if you look the error codes you see that error 506 (the error that baan pops up when a table doesn´t exist) corresponds to Enotable.

Anyway, if works for you it's ok for me :)