How to avoid error in "select xxx, yyy from tb where i in

Hi,

I am writing something where I need to extract particular rows in a table, using a pre-computed row id, like this.

“select xxx, yyy from tb where i in (something)”

However, I found that when something is empty, the above select statement will produce a `type error.

I wonder if there is any common method so that I can keep using similar query, while I will only get an empty table, rather than an error if the list is empty.

Much appreciate for any help.

Gary 

Is is because (something) is not a list?

select xxx, yyy from tb where i in raze enlist (something)

Morten

Hi,

It could be because the something you are passing in is not a list of any number type. For example:

t:( a:ab; b:cd)

q)select from t where i in ()

'type

q)select from t where i in `long$()

a b


In this case if you cast something that is empty to type long you can use it.

Regards,

Thomas Smyth

AquaQ Analytics

Thanks Thomas,

Yes this indeed solve the problem. Sometimes I just got some wired `type error where I cannot figure out.

For example I had once tried to do

  1. update aaa:something from tb

and 
2) update aaa:something from tb where xxx

  1. always Okay and 2) is produce a `type error.

I spent like 30 mins and figured out that that is because update in 2)

change the type of some row in the columns, while 1) change

all rows to a new type, so that no `type error will be produced.

sometimes this kind of errors is difficult to figured out.