Any Option to Change Table Name Dynamitacally in a Form Application?

I have a form application to enter some data in a particular table I want to change Table Name Dynamically by using a global variable. In my global variable i store a table name depending on some conditions and i want, when the application is run then it should change the Table Name which i have already stored in a global variable. All tables are same structure and same primary key in mySQL.

[ATTACH=CONFIG]n70054[/ATTACH]

Capture.PNG

I would not get my hopes too high on directly changing table of a form. ScriptCase works well for fast generating grids, forms etc. for already defined database tables and views. The applications’ source code are generated up front based on this.

So, you have to be creative to accomplish something similar to the same effect:

I would try to work with views, i.e. creating a view and base my form application on that. Instead of calling the form application directly, I would put in a blank application to be called as an intermediary. The blank application can then change the definition of the view, making sure that all fields are included with identical column names and data types – otherwise the form application will run into trouble. This might work, but you will have to try it out.

You will have to create the view against an initial table, so that the view exists for you to create the form application in the first place.

Also, the logged in user will need database privileges for changing views.

Let us know, if it works.

Hrm… Unfortunately, form does not seem to work when using views as table. I get an error when generating the application, even if a view can be selected as table.
I really thought that I had seen editable views somewhere. Perhaps it was just for grids where it works fine.

Thanks Orion

Yes form does not work. when using views as table.

I used a simple concept for this :created a temporary table with same structure and created form application with this table and when i saved the data in the temporary table then using the OnAfterUpdate Event it transfers the data to its global variable table name, and every time delete data from the temporary table. But when there are multi user then problem arises

I Know this is not the solution but i think there is a macro like sc_label () to change the field label Dynamically, we also need a macro to change Table Name Dynamically.

Best Regards,

Excellent idea with the temporary table and transferring the data to the final table.

I am wondering if you could have an extra field with the user-id in the temporary table (it may just be a normal table in the database) and have a criteria for the form with the user-id taken from a global variable. There is an SQL section in form apps with a where text box for the criteria. The global variable can then be reused when transferring and deleting records from the temporary table. I think that this might just work.

Yes Orion

I faced the problem with the user_id but i not only delete data from temporary table i used a mySQL statement TRUNCATE TABLE temporary table.name to delete data and reset the user_id in temporary table, then calculate maximum user_id from global variable table name and replace temporary table user_id with this user_id + 1. This is a silly logic but i can’t find any solution.

[I]But i think it might be possible to change Table Name Dynamically. Suggestion to SC can be update in next up-gradation, Add a option in SQL section Use Variable As Table Name?

When SC generate source code then save Global Variable name as a Table Name which i define in a Application and when run the particular Application then use Global Variable name as a Table Name…:)[/I]

Ok, but I was thinking that you could just use a normal database table not a temporary table as such and the user-id could be the login user-id. Thus, when you move the data to the table just use a insert…select and normal delete afterwards, both based on this login user-id. But perhaps it won’t work because I don’t fully see the logic of your application and tables.

Certainly, you can try to suggest the idea of dynamic table name to ScriptCase. Not sure how they are going to prioritise it.