# Inserting into a table loaded from file

**URL:** <https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [September 21, 2016, 5:03pm UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253 "2016-09-21T17:03:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtrader](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@rtrader](https://forum.kx.com/u/rtrader)\
**Post date:** [September 21, 2016, 5:03pm UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253/1 "2016-09-21T17:03:00Z")

</div>

I am having an issue when trying to insert into a table that I have loaded from a file. I save my default name space by doing this:  
`:savedinstance.bin set get `.

In another q session i load the file by doing :

`. set get `:savedinstance.bin&nbsp;

However, now when i try to a table that exists in that namespace I get a type error. If I redfine the table to a empty table with the same columns etc etc I can insert no problem. Any idea on why this is the case?

---

<div class="post-metadata">

**Author:** ![Aidan\_O\_Gorman](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Aidan\_O\_Gorman](https://forum.kx.com/u/Aidan_O_Gorman)\
**Post date:** [September 22, 2016, 9:23am UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253/2 "2016-09-22T09:23:00Z")

</div>

It sounds as though you’re inserting into something that isn’t a table when it gets loaded in. What’s the table’s name and meta data? Also what is the result when you run&nbsp;(get[`:saved data.bin])[`\<tablename\>].&nbsp;

Is the table splayed? You can’t insert data into a splayed table but you could if you redefined it.

Aidan

---

<div class="post-metadata">

**Author:** ![sohagan](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@sohagan](https://forum.kx.com/u/sohagan)\
**Post date:** [September 22, 2016, 11:16pm UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253/3 "2016-09-22T23:16:00Z")

</div>

Can you just post your example and show the issue first hand? What you are describing can’t be replicated…

q)t:(10?10)

q)`t insert 1

,10

q)v:10

q)func:{10+x}

q)`:ns set get `.

`:ns

q)delete t,v,func from `.

`.

q)key`.

`symbol$()

q)`. set get`:ns

`.

q)key`.

`t`v`func

q)`t insert 11

,11

Sean

---

<div class="post-metadata">

**Author:** ![rtrader](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@rtrader](https://forum.kx.com/u/rtrader)\
**Post date:** [September 23, 2016, 2:15pm UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253/4 "2016-09-23T14:15:00Z")

</div>

this is where it gets weird, if I save the namespace and load the table the same day without a restart I have no issues inserting. However, after a reboot of my machine if i load my namespace I get errors when inserting. For example, I have saved a namespace a few days ago, today I ran another instance with the same code and saved the namespace. If i try to load the namespace i saved a few days ago the insert does not work. The one that I saved today however does work. I tried this:  
tick200 insert (“z”$cbarstart),(“z”$tabdatal[0]),(“f”$cbaropen),(“f”$tabdatal[4]),(“f”$cbarhigh),(“f”$cbarlow),(“j”$cbarvolume),(“f”$cbarvwap),(“f”$netchg),(“f”$totchg),(“f”$effratio),(“f”$thatshit),(“f”$diff),(“f”$valuep),(“f”$truncValue),(“f”$fish),(“f”$upmajor),(“f”$downmajor),(“f”$exits),(“f”$exitl),(“f”$pos),(“f”$entryprice)

but it results in a type error

meta tick200 yeilds:

![]()

I also verified that the variables are all defined and are the same type as the table columns by executing :

(“z”$cbarstart),(“z”$tabdatal[0]),(“f”$cbaropen),(“f”$tabdatal[4]),(“f”$cbarhigh),(“f”$cbarlow),(“j”$cbarvolume),(“f”$cbarvwap),(“f”$netchg),(“f”$totchg),(“f”$effratio),(“f”$thatshit),(“f”$diff),(“f”$valuep),(“f”$truncValue),(“f”$fish),(“f”$upmajor),(“f”$downmajor),(“f”$exits),(“f”$exitl),(“f”$pos),(“f”$entryprice)

![]()

This is totally bizarre completely mind-boggled&nbsp;

---

<div class="post-metadata">

**Author:** ![Aidan\_O\_Gorman](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Aidan\_O\_Gorman](https://forum.kx.com/u/Aidan_O_Gorman)\
**Post date:** [September 26, 2016, 10:13am UTC](https://forum.kx.com/t/inserting-into-a-table-loaded-from-file/11253/5 "2016-09-26T10:13:00Z")

</div>

Have you perhaps forgotten a back tick on your insert statement or is that variable defined as a symbol naming another table elsewhere.

Are you loading any splayed or HDB tables before attempting to insert? Is the output of tick200 a table or a file path? Can you paste the output of tick200 when executed directly from a q prompt (or the first few rows at least).

Thanks,  
Aidan
