# Updating a linked column

**URL:** <https://forum.kx.com/t/updating-a-linked-column/9933>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [June 5, 2015, 1:02pm UTC](https://forum.kx.com/t/updating-a-linked-column/9933 "2015-06-05T13:02:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoffmanroni1](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@hoffmanroni1](https://forum.kx.com/u/hoffmanroni1)\
**Post date:** [June 5, 2015, 1:02pm UTC](https://forum.kx.com/t/updating-a-linked-column/9933/1 "2015-06-05T13:02:00Z")

</div>

Hi all,

I am trying to update a linked column but am receiving an error.

I have a function similar to

`updateCol:{[d]`:c:/hdb/2015.05.01/trade/ set (update mas:`mas!mas.sym?sym from select from trade where date=d)};`

I added the original linked col by using&nbsp;

` addcol[`:/hdb;`trade;`mas;{`mas!mas.sym?get(`)sv x, `sym}];`

but its out of date now and want to update it.

When I run the updateCol function I get an access is denied error. &nbsp;I think the problem lies in the “select from trade where date=d” part because when I pull this out of the function the table is too large. &nbsp;Is there another better way to do this?

---

<div class="post-metadata">

**Author:** ![david\_demner](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@david\_demner](https://forum.kx.com/u/david_demner)\
**Post date:** [June 5, 2015, 8:01pm UTC](https://forum.kx.com/t/updating-a-linked-column/9933/2 "2015-06-05T20:01:00Z")

</div>

it may be because select from trade where date=d keeps a reference to the file on disk, which is then locked when you try to set\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

You can read the column into memory and then writ it down:\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

updateCol:{[d] f set `mas!mas.sym?get f: `:c:/hdb/2015.05.01/trade/sym)};\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

which would also be way more efficient because you are only reading/writing the one column\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

**From:** [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com) [[mailto:personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com)] **On Behalf Of** Roni Hoffman  
**Sent:** Friday, June 5, 2015 5:02 AM  
**To:** [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com)  
**Subject:** [personal kdb+] Updating a linked column\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

Hi all,\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

I am trying to update a linked column but am receiving an error.\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

I have a function similar to\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

updateCol:{[d]`:c:/hdb/2015.05.01/trade/ set (update mas:`mas!mas.sym?sym from select from trade where date=d)};\<o:p\>\</o:p\>

I added the original linked col by using&nbsp;\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

&nbsp;addcol[`:/hdb;`trade;`mas;{`mas!mas.sym?get(`)sv x, `sym}];\<o:p\>\</o:p\>

but its out of date now and want to update it.\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

When I run the updateCol function I get an access is denied error. &nbsp;I think the problem lies in the “select from trade where date=d” part because when I pull this out of the function the table is too large. &nbsp;Is there another better way to do this?\<o:p\>\</o:p\>

–  
Submitted via Google Groups

---

<div class="post-metadata">

**Author:** ![hoffmanroni1](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@hoffmanroni1](https://forum.kx.com/u/hoffmanroni1)\
**Post date:** [June 5, 2015, 8:35pm UTC](https://forum.kx.com/t/updating-a-linked-column/9933/3 "2015-06-05T20:35:00Z")

</div>

I see, thanks very much David
