Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5826 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello folks,

is there a way, through a script, to check out if a table exists?

I need to perform some steps only if a table exists but I can't find how to make it works.

Thanks

Posted

Not really. I suppose you could use the TableNames() function, but I'm not going to spend time on this. All I wanted to say is that this shouldn't be necessary.

Posted (edited)

Thank you so much for your reply.

Maybe this is not necessary for you but it is necessary for me.

Look forward for someone else's help.

Have a good 1!

Edited by Guest
Posted

Can you elaborate more on the logic of your script and why you need to confirm its existence? How often do you run the script and how often is the schema modified where a table is deleted or created?

Posted

Hi Stephen, sure

basically I'm trying to create a shell for my future development.

and I would like to define a startup script that performs some sub-scripts only if I want those features on that specific database.

So instead removing the sub-scripts themselves, my idea was to delete just the table. For instance let us say I need to log the access to the database. I create a table called accesses and in my startup script I say if accesses exists add a new record on it. So if I don 't want/need this feature what I have to do is remove the table from the specific database instead to modify the startup script itself.

Is there a better way to deal with this issue?

Thanks and have a great evening !!!

Posted

" So if I don 't want/need this feature what I have to do is remove the table from the specific database instead to modify the startup script itself."

And when the features need to be added back in again, which method would be easier: re-building the database structure and linking back all the references, or un-commenting out a script step?

Posted

Like Vaughan mentioned, I would take the approach of putting the conditional code in to a subscript and only call it if the conditions that this database requires is met, when you add (or remove) the table to the solution un/comment your line in your script or invalidate the condition to the branched subscript.

If you must know if a table exists you could make sure every table has a corresponding layout, putting a text object on the layout with object names give it the name that you want to know like "REQUIRED_TABLE_XYZ" then on startup loop thru each layout in the solution building a list of object names on each layout with GetLayoutObjectAttribute ( ) then parse that list out and determine your branching logic appropriately. That seems like a lot of extra work.

I would rather set a global field on a environment table or set global variable on startup or rather a custom function that defines the solution parameters and branch your script accordingly.

This topic is 5826 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.