KX Community

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

Home Forums kdb+ why sv needs ,’ here? Re: why sv needs ,’ here?

  • davidcrossey

    Member
    June 4, 2023 at 12:00 am

    You’ll get a type error without the each, because you need to create a scalar from each vector (i.e. each pair of symbols)

     

    q)t:([]sym:`ORCL`APPL;src:`L`R) t 
    sym src 
    -------- 
    ORCL L 
    APPL R 
    
    q) update symsrc:` sv (sym,'src) from t 
    'type [0] 
    update symsrc:` sv (sym,'src) from t ^ 
    
    q) update symsrc:` sv'(sym,'src) from t 
    sym src symsrc 
    --------------- 
    ORCL L ORCL.L 
    APPL R APPL.R

     

    Bonus tip – as shown above, you can avoid using a lambda by using parenthesis so the parser doesn’t interpret the comma as a new column statement.