# ExecuteSQL, How to . .

**URL:** <https://the.fmsoup.org/t/executesql-how-to/5381>\
**Category:** Questions\
**Tags:** sql\
**Created:** [April 17, 2026, 8:47pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381 "2026-04-17T20:47:57Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 21, 2026, 8:53pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/21 "2026-04-21T20:53:34Z")

</div>

> [@TKnTexas](#):
>
> In other files that have more tables, I need to create the "X" relationship to each table that gets an IMPORT or EXPORT script?

It all depends on context. To access data in a single record table you do need to connect the table so that the data is visible in the correct context.

To avoid context issues you can do a bit more work upfront. Create a globals table. That is a table that is full of global fields named after the data fields that you have in your single record table. At startup (usually) you have a script visit the single record table and pass the data from all of the fields into the fields in the global table. When the data is in a global field it can be seen from any table in your system without need any relationship at all.

---

<div class="post-metadata">

**Author:** ![TKnTexas](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@TKnTexas](https://the.fmsoup.org/u/TKnTexas)\
**Post date:** [April 23, 2026, 7:34pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/22 "2026-04-23T19:34:38Z")

</div>

I liked this idea. I created a table in ONE of the 22, MA\_Pref.Local with four global fields.

I created a script to:

![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/5/5b64ff8bf7ea1a66ec5c51b1e74bd9d8e651d2d0.png)

When I run the script I get that the Local fields are not modifiable.  
I have an **X-Relationship** between the two Tables:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/a/a8a99de88a77c141854d2191be50abea50e75006.png)

When you have the opportunity, I would appreciate any feedback.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 24, 2026, 3:24am UTC](https://the.fmsoup.org/t/executesql-how-to/5381/23 "2026-04-24T03:24:55Z")

</div>

You are meant to set the global field to the value of the settings stored in the normal data fields.

---

<div class="post-metadata">

**Author:** ![TKnTexas](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@TKnTexas](https://the.fmsoup.org/u/TKnTexas)\
**Post date:** [April 24, 2026, 2:27pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/24 "2026-04-24T14:27:49Z")

</div>

MA\_Pref.Local is global fields... I am trying to set the values when opening the file, in this case APInvoice.FMP12. Setting the GLOBALS to the values in the MA\_Pref table.

I would think the script I posted would do it. But I do not know why the GLOBALS in MA\_Pref.local are not modifiable.

Playing around, trying different processes. I deleted MA\_Pref.Local.

I used IMPORT RECORDS to create a new MA\_Pref. I changed the FieldName.X to GLOBAL.

Instead of using SET FIELD to initial the values, I used an Import Record script step. Each time the files are opened, that will run.

@Malcolm Thank you very much for the patience and assistance. Now I need to do my "job" of accounting. Have a great weekend.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [April 24, 2026, 2:59pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/25 "2026-04-24T14:59:03Z")

</div>

> [@TKnTexas](#):
>
> I do not know why the GLOBALS in MA\_Pref.local are not modifiable.

Possibility: There must be at least one record in the MA\_Pref.local table if you are attempting to set the global field value via a relationship.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [April 24, 2026, 3:19pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/26 "2026-04-24T15:19:00Z")

</div>

![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/5/5b64ff8bf7ea1a66ec5c51b1e74bd9d8e651d2d0.png)

> [@TKnTexas](#):
>
> MA\_Pref.Local is global fields... I am trying to set the values when opening the file

The screenshot of script steps (above) does not align with the quote above. The script steps were set up with the _non-local_ fields as the target field to be set. In other words, it is the reverse of what is actually desired.

**As an example:**

Line 4 attempts to set the field: `MA_Pref::Finance_Server.x`

With the value of: `MA_Pref.Local::Finance_Server.x`

If `MA_Pref.Local` is the table occurrence with the global fields, then it should be the other way around.

---

<div class="post-metadata">

**Author:** ![TKnTexas](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@TKnTexas](https://the.fmsoup.org/u/TKnTexas)\
**Post date:** [April 24, 2026, 7:21pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/27 "2026-04-24T19:21:32Z")

</div>

@steve_ssh I did get very confused. The MA\_Pref file has the one table with one record. Four Fields holding paths.

In the recipient files. I created MA\_Prep with global fields, with one record.

My solution changed from a script that uses SET FIELD to set the paths in the four fields, to Importing the record from MA\_Pref to the MA\_Pref.Local in each field. Twice (that I have added it to a file) that has worked.

Modifying the scripts in the recipient files has not worked. I work with setting variables to import using the GLOBAL fields for the path and adding the file name. Has not worked.

To get my work done, I am having to hard code the new paths.

I do appreciate the assist. This is my most challenging project.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [April 24, 2026, 8:06pm UTC](https://the.fmsoup.org/t/executesql-how-to/5381/28 "2026-04-24T20:06:48Z")

</div>

> [@TKnTexas](#):
>
> To get my work done, I am having to hard code the new paths.

It sounds like the hard-coding will get you by for the time being.

As far as coming back to it some other time, it seems to me like you are fairly close in that you have a handful of good ideas to work with. I think that what will get you to success will be just a little bit of study to come up to speed with a few FM topics, or perhaps an increased focus on the details involved.

[Previous page](https://the.fmsoup.org/t/executesql-how-to/5381.md?page=1)
