KX Community

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

Home Forums kdb+ How to convert below functional select query to a QSQL format. Re: How to convert below functional select query to a QSQL format.

  • rocuinneagain

    Member
    February 2, 2024 at 12:00 am

    The first example line you show is creating parse trees and then evaluating them with value

    https://code.kx.com/q/basics/parsetrees/

    You then replace the parse tree with a qsql statement which evaluates, this means you no longer need value:

    tables[]!{count select from x} each tables[]

    The debugger uses ^ to show you exactly where the error is thrown

    // ^ tells us the error happened when value was run

    q)tables[] ! ( { count value ( select from x ) } each tables [] ) 'type [2] { count value ( select from x ) } ^ 
    
    q))select from x // select from x returns a table a - 1 2 3 q))value select from x //Running value on a table is not a valid command 'type [4] value select from x ^ 
    
    q))count select from x //We should run count directly on the returned table 3

    See: https://code.kx.com/q/basics/debug/