# \[Solved\] Call a Database dynamically

**URL:** <https://community.thunkable.com/t/solved-call-a-database-dynamically/585800>\
**Category:** Questions about Thunkable X\
**Tags:** database, solved\
**Created:** [May 23, 2020, 4:29am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800 "2020-05-23T04:29:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![thestrengthinstitute](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thestrengthinstitute](https://community.thunkable.com/u/thestrengthinstitute)\
**Post date:** [May 23, 2020, 4:29am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/1 "2020-05-23T04:29:17Z")

</div>

Hi,

Is there a way to **choose the name of a table dynamically**?

So I have 18 items in a list and 18 corresponding databases.  
Each list item on selection displays the corresponding database.

So right now everything is hard-coded:  
If item-1 selected, call table 1  
else if item-2 selected, call table 2  
else if…  
else call table 18.

Is it possible to make this code smaller by choosing table name dynamically,  
like \> **if item-i selected, call table i**?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [May 23, 2020, 9:47am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/2 "2020-05-23T09:47:48Z")

</div>

Hi,

Use this block

![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/15b5f0e503da608117cbf5e1ca5bb9187cf47145.png)

---

<div class="post-metadata">

**Author:** ![thestrengthinstitute](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thestrengthinstitute](https://community.thunkable.com/u/thestrengthinstitute)\
**Post date:** [May 24, 2020, 7:05am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/3 "2020-05-24T07:05:15Z")

</div>

Thanks @actech. Is this possible to do for a local database too? I don’t see the option in a local database.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [May 24, 2020, 7:14am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/4 "2020-05-24T07:14:08Z")

</div>

What do you mean by “local database”? There is no such component in Thukable X.

---

<div class="post-metadata">

**Author:** ![thestrengthinstitute](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thestrengthinstitute](https://community.thunkable.com/u/thestrengthinstitute)\
**Post date:** [May 24, 2020, 7:16am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/5 "2020-05-24T07:16:29Z")

</div>

![Untitled](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9ab3f74ea1e85a805bab97fbd23476d3bcb127c3.png)

This one.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [May 24, 2020, 7:18am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/6 "2020-05-24T07:18:51Z")

</div>

Clearly, this is actually a local table ).

Now I will think about how to do this, because I do not see an easy way yet.

Unfortunately, Any Components do not have the Local DB type in the list of components, so it was very easy to solve your question by specifying the name of the table you need in the set Any Component block. I think you need to make a request on github to add the Local DB component to the list of components for the get and set Any Components blocks.

 ![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/2/92ba961c100eb8bc3bd2fe78d999cc72e0a68ee6.png)

---

<div class="post-metadata">

**Author:** ![thestrengthinstitute](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@thestrengthinstitute](https://community.thunkable.com/u/thestrengthinstitute)\
**Post date:** [May 24, 2020, 7:54am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/7 "2020-05-24T07:54:53Z")

</div>

Thanks @actec. I think till then I will use AirTable

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [May 24, 2020, 7:59am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/8 "2020-05-24T07:59:17Z")

</div>

You can easily build your tables using JSON, if you know how to work with this format, or try using a delimited string and a List component.

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [May 27, 2020, 11:52pm UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/9 "2020-05-27T23:52:40Z")

</div>

@actech  
I’m trying to utilize the “tablename” and “viewname” blocks, but I can’t get the data viewer to update at all to the new table. I’ve tried the two solutions below. Neither work.

Have you been able to get it to work? Also, what do you mean by build your own tables with JSON? How do you get the dataviewers to update with the JSON?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/c/ac67930fb81ad81a81ff163fa575b86eaa59b7d4.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/0/60b3c43a5652f78729795cda542706482cefac11.png)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [May 28, 2020, 5:42am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/10 "2020-05-28T05:42:11Z")

</div>

I see that the problem with table access blocks hasn’t been solved, so you can’t use blocks to switch tables.

A table is a string of data with delimited fields and rows (CSV). A lot of tables is a data string with field, row, and table separators. For this reason, you can implement all tables as a delimited text string. But I recommend that you learn the JSON format, which allows you to work with tables in a simpler way.

You can use Firebase to work with tables, but here again you will need JSON knowledge.

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [May 28, 2020, 8:36pm UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/11 "2020-05-28T20:36:44Z")

</div>

Unfortunately the new data viewer components don’t work with Firebase, otherwise that would probably be my go to.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:28am UTC](https://community.thunkable.com/t/solved-call-a-database-dynamically/585800/12 "2024-11-08T11:28:54Z")

</div>


