Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

update where symbol length less than 3 characters KDB+/Q

I have a table like this:

test:([]column1:`A`B`C`D`E;column2:`Consumer`RealEstate`27`85`Technology)

I need to write an update query where the character count of column2 is 2 or less, but I couldn’t find any way to reference the character length of a symbol to use in a where clause. How would I write a query like that so my result is the following?

test:([]column1:`A`B`C`D`E;column2:`Consumer`RealEstate`NewCategory`NewCategory`Technology)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One way to accomplish what you want is to convert the symbols into strings (i.e. lists of chars) and apply the where clause to the count of each of those strings:

update column2:`NewCategory from `test where 3>count each string column2

(using a backtick on the table name here, assuming you want to apply the change in place)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading