KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Assigning upd inside a function and replay TP log

  • Assigning upd inside a function and replay TP log

    Posted by gazi on March 19, 2025 at 2:18 am

    I have created sample tp logs and I want to replay it. However, if the upd function is defined inside a function, the error occurred when I replay. Is it related to scope or namespace? Thanks.

    I’ve simplified my code and put it below.

    Create TP log

    tableName:`students;
    students:([] id:1 2; name:`Foo`Bar);
    
    `:tpLog set ();
    h:hopen`:tpLog;
    {h enlist(`upd;tableName;value x)} each select from tableName;
    hclose h
    

    \\

    (The code formatting mess up and I can’t fix it. Please ignore those html tags.)

    //Load TP log (with error)
    students:([]id:`long$(); name:`symbol$());
    f:{[x]
      upd:insert;
      -11!`:tpLog
      }["foo"];
    <p><br></p></pre><pre>//Load TP log (without error)
    students:([]id:`long$(); name:`symbol$());
    upd:insert;
    -11!`:tpLog
    

    The error

    'upd
      [3]  /Users/gazi/src/kdb-test/test.q:4: 
      upd:insert;
      -11!`:tpLog
         ^
      }
    
    • This discussion was modified 1 week, 5 days ago by  gazi.
    • This discussion was modified 1 week, 5 days ago by  gazi. Reason: formatting
    • This discussion was modified 1 week, 5 days ago by  gazi. Reason: formatting again
    • This discussion was modified 1 week, 5 days ago by  gazi. Reason: formatting again again
    • This discussion was modified 1 week, 5 days ago by  gazi.
    gazi replied 1 week, 3 days ago 2 Members · 4 Replies
  • 4 Replies

Log in to reply.