MacSig Posted December 12, 2008 Posted December 12, 2008 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
comment Posted December 12, 2008 Posted December 12, 2008 Maybe, but if the person who writes the script doesn't know if a table exists then something is very wrong.
MacSig Posted December 12, 2008 Author Posted December 12, 2008 Thanks for your reply. Could you please let me know how I can check it out?
comment Posted December 12, 2008 Posted December 12, 2008 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.
MacSig Posted December 12, 2008 Author Posted December 12, 2008 (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 December 12, 2008 by Guest
Ocean West Posted December 12, 2008 Posted December 12, 2008 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?
MacSig Posted December 12, 2008 Author Posted December 12, 2008 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 !!!
Vaughan Posted December 12, 2008 Posted December 12, 2008 " 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?
Ocean West Posted December 12, 2008 Posted December 12, 2008 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.
MacSig Posted December 12, 2008 Author Posted December 12, 2008 thanks guys for your point of view. I appreciate it
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now