How to convert below functional select query to a QSQL format.

Hi All,
I am new to kdb and wanted to prepare a report containing information of how many rows are seen in variable rdb tables. For this I see we can get that via below functional query that provide us dictionary with table name and count 
(tables[] ! { count value (? ; x ; () ; 0b ; () ) } each tables[]   
- Above gives me the expected output, but I wanted to perform this via qsql for my understanding. But this gives me the error. 
tables[] ! ( { count value ( select from x ) } each tables [] ) 

I tried to use the implicit argument x and passed it to function which then count the number of rows inside the lambda function and then tried passing it parameter  each tables []  which results into an error. How can I debug this error with some meaningful error thrown and what would be right way to do it ?

Thanks in advance.

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/