Xojo Conferences

« RegEx Speed Test | Home | MBS Real Studio Plugi… »

Create fields in Filemaker database from a Script

Just a quick note: You can create/remove fields form a Filemaker database using scripts. A call like this creates a new field:

MBS("FM.ExecuteSQLOnIdle";"ALTER TABLE TestTable ADD MyField varchar")

We change the table TestTable and add a new field called MyField with type text (varchar).
Also you can remove a field:

MBS("FM.ExecuteSQLOnIdle";"ALTER TABLE TestTable DROP COLUMN MyField")

It is important to use FM.ExecuteSQLOnIdle to avoid a deadlock. So only when the database is not in use (at idle time), you can change it. For next plugin prerelease we updated FM.ExecuteSQL.LastErrorMessage to also report error messages from FM.ExecuteSQLOnIdle.
24 02 13 - 17:47
two comments

Hello, is there any possibility to use FM variables in this function, e.g. ALTER TABLE $table ADD $field $type”">MBS ? I tried some options but it does not work.

Best, J├╝rgen
Jürgen Müller (Email) - 23 06 19 - 15:03

Yes, simply include variables when calculating the SQL string:

ALTER TABLE TestTable ADD “ & $Name & “ “ & $Type">MBS

It may be good to put the name in quotes.
Christian Schmitz (URL) - 23 06 19 - 17:52

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.