KX Community

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

Home Forums kdb+ SQL call function with 2 args

  • SQL call function with 2 args

    Posted by ekallivrousis on September 2, 2021 at 12:00 am

    I have a function which takes 2 arguments. Ill write some pseudo code for an idea

    f:{[x;y] $[x~`1;y;`0]}

    Then i have a table:

    t:([]a:`1`2`3;b:`4`5`6)

    Now i want to call that function and pass a and b to it from an update statement

    update c:f[a;b] from t;

    update c:f[a;b] from t;

    This however doesnt work because its passing the whole column instead of just an item. Now i know if it was just 1 arg i could just do an “each” but I’m not sure how to do that with 2 args.

    ekallivrousis replied 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • willlowe

    Member
    September 2, 2021 at 12:00 am

    You’re right in using an each iterator, by using:

    update c:f'[a;b] from t 
    a b c 
    ----- 
    1 4 4 
    2 5 0 
    3 6 0

Log in to reply.